Liberty Global and Telefonica have agreed to merge their British businesses in a $38 billion deal including debt that will step up the challenge to market leader BT in mobile and broadband.

In the biggest shake-up in the UK telecoms market for five years, the deal will bring together the biggest cable TV provider in Liberty's Virgin Media with Telefonica's O2, the second-biggest mobile operator. 

It marks the latest move by Liberty's veteran billionaire dealmaker John Malone, the US cable pioneer who has pulled off a string of transactions in Europe in recent years.

These include the sale of networks in Germany and central Europe to Vodafone as part of the same trend of combining fixed lines with mobile. 

It will also allow debt-laden Telefonica, which tried and failed to sell O2 in 2016, to extract some cash from the business while keeping a presence in Britain. 

"It's not a secret any more, when 5G meets 1 gig broadband we know magic can happen for customers," Liberty Global CEO Mike Fries told reporters on a conference call, referring to super-fast internet speeds in both mobile and broadband. 

Telefonica's chief executive Jose Maria Alvarez-Pallete said the two businesses would be "much stronger together". 

The parent companies, which expect to achieve £6.2 billion of synergies on an annual basis by the fifth full year after closing, will have equal ownership of the combined entity, they said today. 

The joint venture will invest £10 billion in the UK market over the next five years, helping it to also compete with the likes of Comcast's Sky, the leader in pay-TV, Vodafone and Three.

The companies said the deal would value Telefonica's O2 at £12.7 billion and Liberty's Virgin Media at £18.7 billion, both on a total enterprise value basis, including debt. 

The combination could finally resolve a question over the fate of O2 which has been open since 2016, when European regulators blocked a £10.3 billion takeover by smaller mobile Three UK, controlled by CK Hutchison Holdings. 

Hutchison and fellow major operator Vodafone now face being stranded without their own large fixed-line consumer networks.  

Analysts expect the deal to be approved by regulators. 

While British competition authorities have toughened their approach in recent years, the combination of a mobile network with a broadband network is unlikely to cause major problems. 

BT's 2016 acquisition of EE, bringing together the UK's biggest broadband and mobile operators, was waved through by regulators who reasoned there was little overlap between fixed and mobile operations, and therefore a low risk to competition. 

Both parties expect to receive net cash proceeds at closing following a series of recapitalisations that will generate £5.7 billion in proceeds for Telefonica and £1.4 billion for Liberty, they said. 

Virgin Media Ireland is not included in the merger and will remain a wholly owned subsidiary of Liberty Global.