A statement on its website said the 4G network was finally working again, after having been affected from about 05:30 GMT on Thursday.
Earlier, mobile network equipment supplier Ericsson said that an expired certificate was the reason behind the outage, which also created problems in several other countries. Ericsson UK boss Marielle Lindgren said the "faulty software" that had caused the issues was being decommissioned.
Both O2 and Ericsson issued a joint apology to millions of customers hit by the disruption. "I want to let our customers know how sorry I am for the impact our network data issue has had on them, and reassure them that our teams, together with Ericsson, are doing everything we can," said O2 boss Mark Evans. "We fully appreciate it's been a poor experience and we are really sorry."
O2 is owned by Spain's Telefonica and has the UK's second-largest mobile network after British Telecom subsidiary EE.
The company said voice calls were not affected by the problem, but some O2 customers said they could not make calls or send texts, despite having cellular reception.
The outage also had knock-on effects for other services that use the O2 network, such as Transport for London's electronic timetable service at bus stops, which stopped working for most of Thursday.