EU leaders agreed late on Friday night to a new deal that would give special status to the UK.
The 28 leaders have been thrashing out a deal on Britain's relationship with the European Union since Thursday evening but have only just agreed to a deal.
Prime Minister David Cameron – who wanted reforms in four major areas – was forced to make a number of compromises on the deal, in particular on an emergency brake on benefits for migrants.
Cameron asked leaders on Thursday night for the emergency brake to be extended to 13 years, but it appears that after pushback from France and Eastern European countries, leaders agreed to a seven-year timeframe.
However, that agreement goes further than the original proposal, which suggested that the brake should only last five years.
The prime minister tweeted after a deal was completed and confirmed that he would hold a cabinet meeting tomorrow.
"I have negotiated a deal to give the UK special status in the EU. I will be recommending it to Cabinet tomorrow. Press conference shortly," he tweeted.
The renegotiation could allow him to announce a date for the EU referendum – suggested to be 23 June – as early as tomorrow.
Details of the deal leaked after European Council President Donald Tusk confirmed the deal had "unanimous support".
It included reforms in four major areas:
• Britain will be given an emergency brake on work benefits for migrants that will last up to seven years. This will apply only to newly-arriving migrants; the restriction on benefits can apply to individuals for a maximum of four years.
• Child benefits will be indexed to a migrant's home country for new migrants with immediate effect. That means that child benefits for EU migrants will be capped at the level they would receive in their country of origin. Restrictions will also apply on existing EU migrants from 2002.
• Britain will also be able to opt out of "closer political union," a core tenet of the EU. This means the UK would not be committed to "further political integration into the European Union".
• And finally, Britain will be able to pull a brake to safeguard British businesses and the City. If used, this would require any controversial financial policy to be discussed by EU leaders at a European Council meeting.
The anti-EU "Vote Leave" campaign was quick to criticise Cameron's deal as "bad for Britain." "David Cameron always wanted to campaign to stay in the EU so he only ever asked for very minor changes," Vote Leave's chief executive, Matthew Elliot, said.
"He will now declare victory, but it is an entirely hollow one: the EU courts are still in control of our borders and our laws, we still send £350 million a week to the EU instead of spending it here on our priorities and we have not taken back any control."
But in a press conference, the prime minister insisted that he has "delivered on the commitments" he made on the EU. He urged voters that it would be a "leap in the dark" if Britain voted to leave the EU and it was "a time to stick together."
Ministers have so far not been able to campaign to stay in or leave the EU but it is understood that a gag will be lifted tomorrow morning after a cabinet meeting.
Siraj Datoo is a political reporter for BuzzFeed News and is based in London.
Contact Siraj Datoo at email@example.com.
Got a confidential tip? Submit it here.