The European Union stars and the Union Jack flag hang next to each other this week at the European Parliament in Brussels. (Virginia Mayo/AP)

As Britain has danced on the edge of a European Union exit, continental leaders have repeatedly insisted they want their island neighbor to remain a part of the club.

Now those leaders will have to decide how far they are willing to go to persuade the United Kingdom to stay.

Months of negotiations over British demands to reconfigure its relationship with the E.U. are expected to culminate in a deal at an E.U. summit here this week. British Prime Minister David Cameron has said the outcome of the talks will be critical to persuading his citizens to opt for “in” when the U.K. holds its referendum on membership in the 28-member bloc.

But as late as Wednesday night, Cameron was struggling to win concessions from European counterparts who have been reluctant to grant him the sort of wide-ranging changes he craves.

The tough bargaining by continental leaders reflects the limits of their tolerance toward British demands that have struck some as petty, divisive and distracting at a time when Europe is facing a panoply of existential threats. European leaders want to prevent Britain from bolting. But not at any cost.

“Europe has basically said: ‘We’re trying to help you because we want to keep you in. But at some point, there’s a limit to what you can ask for,’ ” said Karel Lannoo, chief executive of the Brussels-based Center for European Policy Studies. “Ultimately, the British need to make a decision: Are they part of Europe or not?”

The question could be settled as soon as June, assuming Cameron and the other 27 E.U. leaders are able to strike a deal this week. The British prime minister has promised the referendum by the end of 2017, following years of demands from Euroskeptics in his own Conservative Party. But experts say the vote will come far sooner because delay only increases the chances of a vote for “out.” Polling indicates a contest that could go either way.

A British departure would mark the first time an E.U. member has chosen to leave the club, which has defined European politics and economics for decades and is credited by backers with helping to keep the peace on a continent scarred by a long history of especially destructive wars.

Experts fear that the country’s exit — popularly known as Brexit — could trigger a broader unraveling of the E.U. at a time when the continent is already grappling with a refugee crisis, renewed Russian aggression, terrorist attacks and a surging far-right.

Along with Germany and France, Britain is regarded as one of the three essential members of the union. But it has long been an ambivalent participant, signing up for the benefits of the single market while opting out of the common currency and Europe’s borderless travel zone.

Cameron’s negotiation is aimed at even further loosening the ties between the U.K. and a Brussels-based bureaucracy that Brexit proponents regard as a stifling infringement on national sovereignty.

His four demands consist of: an opt-out from the E.U.’s founding ambition to forge “ever closer union”; greater power for national parliaments to block E.U. legislation; formal recognition that the euro isn’t the union’s only currency; and permission to restrict benefits for immigrants from within the E.U.

But draft proposals for a deal have proved underwhelming and have been widely mocked by advocates for “out.” Without a more robust package of overhauls, the prime minister risks losing the support of key Conservative allies, including London Mayor Boris Johnson, who has played coy on his E.U. stance.

Cameron on Wednesday night was reported to be pushing for last-minute concessions that would allow him to declare victory before he officially launches the referendum campaign, a move expected when he returns home Friday.

The prime minister may have an ally in that cause in German Chancellor Angela Merkel. She told her Parliament Wednesday that British demands for E.U. restructuring were “justified and necessary.”

Keeping the U.K. in the E.U., she said, was “not just in Britain’s but also in Germany’s interest, and that of Europe as a whole.”

But several Eastern European countries have signaled they will fight plans to allow London to restrict social-welfare benefits for European immigrants working in Britain.

Record immigration to the U.K. — much of it fueled by Eastern Europeans seeking better job opportunities — has been one of the main drivers of anti-E.U. sentiment in Britain. That makes the benefit restriction especially critical to Cameron’s plans and leaves him politically exposed if Eastern European countries succeed in watering down the provision.

Even as they seek protections for their workers who have immigrated to Britain, Eastern European governments are blocking attempts to forge a united response to the continent’s refugee crisis. The issue will be on the agenda when European leaders meet Thursday, but few tangible results are expected.

The impasse could ultimately aid the pro-Brexit campaign, which has argued that Britain needs to further distance itself from the chaotic migrant flows on the continent.

“The refugee crisis has made it much harder for the ‘in’ crowd to make their case because it makes the E.U. look even worse,” said Jan Techau, director of Carnegie Europe.

Britain is largely insulated from the refugee crisis; it has a special exemption from the E.U.-wide quota for refugees, and the 19 miles of water between the British and French coasts make it difficult for migrants to reach British shores.

It is that kind of special status that often prompts head-shaking on the continent over why Britain would threaten to leave.

“They’re half-in, half-out,” said Pierre Vimont, who is also with Carnegie Europe. “It’s the best they could ever get.”

Karla Adam in London contributed to this report.

Read more

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

NATO ships to combat migrant-smuggling networks in Aegean

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

Today’s coverage from Post correspondents around the world