MADRID, Feb 2 (Reuters) - Spain's Telefonica SA said it had agreed to buy, with its partner fashion retailer Zara's owner Amancio Ortega, the 40% stake in its unit Telxius that belongs to KKR for 216 million euros ($243 million).

Telefonica and Ortega, through his family office Pontegadea, will become the sole shareholders in the telecom infrastructure operator Telxius via their joint-venture Pontel, Telefonica said in a filing to the market regulator late on Tuesday.

Simultaneously, Pontegadea will raise its stake in Pontel to 30% from 9.99%, the filing said.

Telefonica sold a 40% stake in Telxius to KKR in 2018 for 1.275 billion euros. At the time, Telxius comprised Telefonica's mobile telephone masts and other assets such as subsea cables.

American Tower Corp last year bought most of Telxius's assets for 7.7 billion euros, leaving it much smaller, with only a few subsea cables.

Separating the infrastructure assets into a different unit was part of Telefonica's strategy to maximise the value of its assets before disposing them because infrastructure assets have attracted much higher prices than telecom operators' shares.

Telefonica has sold Telxius assets and other units in a bid to cut debt as the rollout of 5G technology requires heavy investments.

On the other hand, Ortega has invested his proceeds from Zara's parent company Inditex into electricity and telecom infrastructure.

Pontegadea has recently become the largest private investor in Spain's electricity grid operator Red Electrica, with a 5% stake, and also bought a 49% stake in a wind farm operated by Spanish energy group Repsol.

($1 = 0.8872 euros) (Reporting by Corina Pons and Inti Landauro; Editing by Edmund Blair)