US cable giant Comcast has submitted the highest bid in the auction for broadcaster Sky, valuing the company at more than £30bn.
Comcast beat Rupert Murdoch's Fox in a rare blind auction process set by the UK's Takeover Panel.
The firm's chairman and chief executive said it was "a great day for Comcast".
Sky has recommended its shareholders accept the bid, saying it was an "excellent outcome" and "represents materially superior value".
The UK company's 23m subscribers and Premier League football rights make it one of Europe's most profitable TV companies.
Comcast's bid equated to £17.28 per share, beating Fox's of £15.67 per share.
Fox had looked set to take over the 61% of Sky it does not already own until Comcast topped its bid.
In July, Fox raised its offer to £24.5bn, but this was trumped by a £26bn bid from Comcast.
The process has also been beset by regulatory issues amid concerns over media plurality and the degree of Mr Murdoch's influence over the UK media landscape.
Brian Roberts, chairman and chief executive of Comcast, said: "Sky is a wonderful company with a great platform, tremendous brand, and accomplished management team.
"This acquisition will allow us to quickly, efficiently and meaningfully increase our customer base and expand internationally.
"We now encourage Sky shareholders to accept our offer, which we look forward to completing before the end of October 2018."
Jeremy Darroch, Sky chief executive, said it was the "beginning of the next exciting chapter for Sky".
He said: "As part of a broader Comcast we believe we will be able to continue to grow and strengthen our position as Europe's leading direct to consumer media company."
In a statement, Fox said it was "considering its options" for the 39% shareholding it currently has in Sky.
It added: "We are proud to have played such a significant role in building the incredible value reflected today in Comcast's offer."
The future of Sky has been hanging in the balance for more than eight years.
The process began when Mr Murdoch's News Corp company put forward a bid for full control of what was then BSkyB.
That bid was scuppered by the phone-hacking scandal that engulfed Mr Murdoch's UK tabloid newspapers and tarnished the firm's reputation.
The bid was revived in December 2016, by which time News Corp had been broken up, leaving 21st Century Fox as one of its successors.
The process has been complicated by Disney's deal to buy most of Fox's assets, which is due to be completed next year if approved by international regulators.
Analysis: Simon Jack, BBC business editor
In the end this epic battle was settled by a very rare three round auction organised by the UK Takeover Panel.
If the sealed bids had been very close, 21st Century Fox and its new owner Disney may have battled on. But the £30.5bn tabled by Comcast was 10% more than Disney-backed Fox was offering and was described as a knockout blow by people close to the deal.
Both companies wanted Sky and its 23 million subscribers to help them compete against new streaming competitors like Netflix and Amazon. The victory will be sweet revenge for Brian Roberts, the chief executive of Comcast who lost out to Disney in a previous battle to buy 21st Century.
In the end, Comcast perhaps needed it more urgently with their home market in the US dwindling.
But the biggest cheers tonight will be from Sky shareholders - who have seen the value of the company driven up by two deep-pocketed rivals in the auction room. Comcast will pay them £17.28 a share - nearly double what they were worth a year ago.