The broadcaster, controlled by the family of former Prime Minister Silvio Berlusconi, said as a result it now owned the whole of the Premium unit.
It did not disclose any financial details. But a source close to the matter said in exchange for its stake Telefonica would get part of damages Mediaset hopes to get from Vivendi (VIV.PA) in an ongoing legal spat involving the unit.
Telefonica declined to comment.
Mediaset and Vivendi have been at loggerheads since July when the French media giant ditched an agreement to take control of Premium. Mediaset is seeking 1.5 billion euros ($1.7 billion)in damages in the case.
Telefonica originally bought the stake in the Italian pay-TV business at the start of 2015 for 100 million euros in a deal valuing Premium at 900 million euros.
According to the source, Mediaset had reached an agreement with the Spanish group to buy the stake for about 70 million euros and then sell it on to Vivendi.
But the sale did not go through when the deal to sell Premium to Vivendi fell through.
"Telefonica was a passive shareholder in a difficult market and that's why it's decided to sell the Mediaset stake," said a second source with knowledge of the matter.
Reporting by Giancarlo Navach and Stephen Jewkes, additional reporting by Sonya Dowsett in Madrid, editing by Francesca Landini and Toby Chopra