British Prime Minister David Cameron says his country will have a "special status" in the European Union following a reform agreement struck with his 27 EU counterparts.
"I have negotiated a deal to give the UK special status in the EU," Cameron wrote on Twitter.
"I will be recommending it to cabinet tomorrow."
That will fire the starting gun for a fierce campaign for a referendum on Britain's future membership of the bloc expected to be held on June 23, with the outcome deeply uncertain.
European Council President Donald Tusk said EU leaders had agreed unanimously on a package of measures aimed at keeping Britain in the 28-member bloc at an extended summit on Friday night.
Both men made their announcements on Twitter as leaders at a summit dinner reviewed an amended text that resolved outstanding disputes over welfare benefits for migrant workers from other EU countries and safeguards for Britain's financial services sector from euro zone regulation.
"Deal. Unanimous support for new settlement for #UKinEU," Tusk's message said.
The agreement delivered victory to Cameron on several of the key demands on which he chose to fight for what he called "a new settlement" with Europe.
He won a commitment to change the bloc's governing treaties in future to recognise that Britain was not bound to any political union and would have safeguards against financial regulation being imposed on the City of London by the euro zone.
Cameron was concerned to show Britons that he had won concessions that he believes can reduce an influx of EU migrant workers and keep Britain out of any future political integration.
In hours of wrangling with central and east European countries that provide many of Britain's low-paid immigrant workers, he secured the right to curb in-work benefits for up to four years and scale back child benefits for workers whose children remain abroad.
East European countries sought to restrict Cameron's welfare cuts to new arrivals rather than the more than 1 million European migrant workers already in the UK. In the end, both sides emerged with something to show for their negotiations.
A compromise that appeared largely favourable to Britain was found for French concerns about differential treatment for London banks outside the euro zone as well as Belgian grumbles about Britain setting a precedent for states to snub EU integration.
The risks of Cameron's strategy were highlighted on Friday when an opinion poll showed the campaign to leave the bloc had a two percent lead with 36 percent support. The TNS poll showed 34 percent of British voters wanted to stay in the bloc, 7 percent would not vote and 23 percent were undecided.