Sky is to become the UK's second-largest broadband provider after agreeing a deal today to buy rival O2's half a million customer accounts.

The satellite broadcaster has built a business with 4.2 million broadband customers since 2006.

It will pay O2 owner Telefonica €180m for the O2 and BE consumer broadband and home phone businesses.

The deal is due to be finalised in April and will close the gap on market leader BT, as well as place Sky ahead of Virgin Media and TalkTalk.

Around 3.6 million Sky customers take its "triple-play" range of TV, broadband and home telephony services and Sky said the acquisition will provide advantages of scale for its home communications business.

"From a standing start in 2006, we have added more than 4.2 million broadband customers. The acquisition of Telefonica's UK consumer broadband and fixed-line telephony business will help us accelerate this growth," commented BSkyB's chief executive Jeremy Darroch.

Sky said O2 and BE's broadband customers will be switched to its all-fibre network and that it might also pay up to €20mto Telefonica UK for the successful completion of the migration process.

Mobile phone business O2, which has more than 23 million customers in the UK, said the deal would enable it to focus on the roll-out of next generation 4G services.