Prime Minister David Cameron and his E.U. counterparts struck an agreement following marathon negotiations in Brussels. Here's what that means for the country and the possibility of an E.U. without Britain. (Jason Aldag,Adam Taylor/The Washington Post)

Prime Minister David Cameron vowed late Friday to wage a relentless campaign to keep Britain in the European Union after striking a deal with fellow leaders that he said would transform the country’s relationship with the 28-member bloc.

The deal, which followed two days of round-the-clock negotiations in Brussels, paves the way for a June referendum in Britain on the country’s long-ambivalent membership. If the country leaves the E.U., it would become the first country to do so, and its departure could trigger a broader unraveling at a time when the union faces greater challenges than at any point in decades.

Cameron had demanded far-reaching concessions from his E.U. counterparts, saying that he needed to prove to increasingly populist voters that an institution often seen in Britain as an overbearing infringement on national sovereignty could loosen its grip. But continental leaders, who support keeping Britain in the club, drove a tough bargain, and some bridled at what they regarded as a British attempt to blackmail the bloc into giving the country a special deal.

In the end, Cameron received significantly less than what he had initially sought. But he still claimed victory Friday night and immediately pivoted to what is certain to be an emotional and bitterly fought campaign over the country’s future in the body that has defined Europe’s postwar order.

“The British people must now decide whether to stay in this reformed European Union or to leave,” he said. “This will be a once-in-a-generation moment to shape the destiny of our country.”

Speaking at a Brussels news conference, Cameron then made a forceful case for Britain to stay, saying that the deal he had negotiated addressed the country’s — and his own — misgivings about an institution he has often derided as bureaucratic and dysfunctional.

“I do not love Brussels; I love Britain,” he said. But staying in the bloc gives his country “the best of both worlds,” with the opportunity to keep the benefits of E.U. membership while “staying out of the parts of Europe that don’t work for us.” An exit, he said, represents “a leap in the dark.”

Campaigners for a British exit — popularly known as Brexit — vehemently disagreed. Nigel Farage, leader of the anti-E.U. U.K. Independence Party, tweeted that the agreement was “a truly pathetic deal. Let’s Leave the EU, control our borders, run our own country and stop handing £55m [$80 million] every day to Brussels.”

The Brexit campaigners are not limited to Cameron’s political foes. Some of his top ministers are expected to defy the prime minister and campaign for an exit, including Justice Secretary Michael Gove. London Mayor Boris Johnson, another leading Conservative who has made no secret that he covets Cameron’s job, has also toyed with supporting the “out” campaign — and will probably announce his allegiance on Saturday.

Polls once showed a clear majority for “in.” But they have tightened markedly in recent months, and most now show that the contest could go either way. The United States and other major British allies have lined up in favor of Britain staying in the E.U., arguing the country’s influence would be vastly diminished if it leaves.

Cameron did not give a date for the referendum Friday night, but it is widely expected to be held on June 23. The prime minister, who will convene a meeting of his cabinet and officially launch the campaign on Saturday morning, promised in last year’s general election that he would give voters an up-or-down choice by the end of 2017.

If Cameron does opt for a June referendum, it will be because he and his top advisers believe that the risk of British exit only grows the longer the country goes without a vote. But holding the poll in the summer, when the continent could be inundated by hundreds of thousands of asylum seekers, is a risky bet.

E.U. officials expressed hope Friday that they had given Cameron enough to secure an “in” vote. “I deeply believe that the United Kingdom needs Europe, and Europe needs the United Kingdom,” said European Council President Donald Tusk. “To break the link now would be totally against our mutual interest.”

But Tusk also acknowledged that Britain has long been a special case, retaining its membership but staying out of the common currency and the free-movement Schengen zone. In a pointed reference to Cameron’s comments, Tusk concluded his remarks late Friday by saying, “I love Britain and I love Brussels.”

Special exemption

European leaders who gathered this week in Brussels, the E.U. headquarters, were reluctant to give Cameron the wide-ranging concessions he had demanded, and the result was 40 hours of talks that at times were heated.

The deal was originally supposed to be sealed Friday over “an English breakfast,” with E.U. leaders gathered around a table piled high with bacon and beans. But as negotiations that began Thursday afternoon hit a series of snags overnight, plans for breakfast were pushed back to an English brunch. Then lunch. Then high tea. The presumably famished leaders finally sat down to a dinner of veal fillets and polenta late Friday night — and agreed on a document that bridged the wider-than-expected gaps.

The deal gives Britain a special exemption from Europe’s vow of “ever-closer union”, establishes financial protections for countries that do not use the euro, creates a national veto over E.U. legislation and, most controversially, gives Britain permission to limit benefits paid to immigrants from within the E.U.

All four measures would loosen the bonds of continental integration, and each proved a difficult sell to reach the unanimous agreement that the E.U. requires. The French pushed back against attempts to weaken financial regulations. Eastern Europeans called foul on restrictions to benefits. The Germans fretted that abandoning the goal of ever-closer union could scupper the European project.

Other variables also came into play. Before signing off on a deal, Greek negotiators reportedly sought a promise that the E.U. would not shut the country’s northern border to migrants and refugees. Such a move, which several E.U. members have advocated, could effectively trap thousands in Greece and prevent them from reaching the countries in northern Europe where they hope to settle.

‘People’s show’

It remains an open question whether Cameron received enough to sway his electorate. Brexit advocates insist that the country is being weighed down by its ties to the continent, particularly by the open borders to European immigration that are required under E.U. treaties.

Cameron said Friday that the benefits-related changes will help limit net migration to Britain, which is at an all-time high. Despite vigorous objections from Eastern European leaders, Cameron won the right to trigger “an emergency brake,” with workers having to pay into Britain’s system for four years before they can receive certain benefits.

European leaders generally played down the extent of the changes, with European Commission President Jean-Claude Juncker describing them as narrowly targeted. Experts agreed that the changes will not fundamentally alter the E.U. But much now depends on how they are received in Britain.

European leaders are mindful that a British exit could be the start of a broader disintegration, with Euroskeptic forces in their own countries likely to be emboldened if one of the cornerstones of the E.U. project departs.

Even before the negotiations were complete, Cameron was facing defections at home. One of the most senior members of his Cabinet, Gove, will join the “out” campaign, the BBC and other media outlets reported Friday evening.

In his news conference late Friday, Cameron described Gove as one of his “oldest and closest friends,” who has wanted to get Britain out of the E.U. for decades. He said he was “disappointed but not surprised” by Gove’s decision.

Most of the government’s other top officials were expected to stick with the prime minister and support the “in” campaign. But some leading Conservatives have yet to show their cards, including Johnson, who would give the “out” movement a charismatic leader.

Cameron played down the impact that any one politician might have on the outcome, noting that the politics of in versus out cross party lines.

“In the end, this isn’t the politicians’ show,” he said. “It is the people’s show.”

Adam reported from London.

Read more:

Spring could bring a fresh surge of refugees. But Europe isn’t ready for them.

In supposed no-go zone, British Muslims, Christians say no to fanatics

Even Europe’s humanitarian superpower is turning its back on refugees