The UK's second largest operator, which demerged from BT in 2001, has been seen as a target for months after Germany's Deutsche Telekom and Dutch group KPN revealed they had tried and failed to put together a joint bid.
The board of O2 has backed the Telefonica deal, which will give the Spanish company an entry into two of Europe's biggest markets of the UK and Germany. It already has substantial operations in Spain and Latin America.
O2 said its brand and UK structure would remain in place, with the impact on the company's 10,000 strong UK workforce - mainly in Slough and Leeds - limited by the lack of overlap between the two companies.
The deal could yet be hijacked by a rival telecoms company - a view held in the City as O2 shares rose above the offer price of 200p to 204.75p, a jump of 25% on the company's share price on Friday night.
O2 has one of the largest shareholder bases among FTSE 100 Index companies, with the majority of its 730,000 investors gaining shares when the former BT Cellnet subsidiary split from parent company BT in 2001.
At one point in 2002 shares were languishing at 37p but the company is now worth the same as its former parent at around £18 billion.
If today's deal receives shareholder approval it will leave four of the five mobile operators in the UK under foreign ownership. Orange is part of France Telecom, T-Mobile is owned by Deutsche Telekom and Hutchison Whampoa has 3.
Shares in Virgin Mobile jumped more than 10% as analysts said the O2 offer put pressure on other operators to bolster their UK subscriber bases.
Investec analyst Christian Maher said Telefonica may struggle to compete if Deutsche Telekom made a rival bid for O2.
He added: "The synergies available to Deutsche within the UK in particular must be significantly higher than those available for Telefonica, where there is no geographical overlap."
Telefonica, which has around 173,000 staff and 145 million customers, anticipates annual cost savings of some £200 million by 2008, including from handset and equipment purchasing.
Peter Erskine, chief executive of O2, who will remain at the group, described the deal as an "excellent opportunity" for O2, which analysts believe is too small in the current market to survive on its own.
He added: "It's also good for customers. Telefonica have no overlapping territory, so they will be able to offer our customers better roaming and better services around the world.
"Finally, it's very good for our people. Because there's no overlapping territories, we can really build on what we've got, as opposed to having to integrate and rationalise jobs."