Prime Minister David Cameron is negotiating changes to Britain’s relationship with the European Union ahead of a referendum on whether the country should remain a member of the bloc. (Hannah Mckay/Reuters)

Prime Minister David Cameron announced Tuesday that he will allow his cabinet ministers to campaign for or against keeping Britain in the European Union.

Cameron is negotiating changes to Britain’s relationship with the E.U. ahead of an in-or-out referendum that he said will take place before the end of 2017. He has said that he will back staying in the E.U. if his push for reforms succeeds, but he has not ruled out campaigning to leave if he does not get the concessions he wants.

Cameron told the House of Commons that at the end of the negotiations, “there will be a clear government position, but it will be open to individual ministers to take a different personal position while remaining part of the government.”

It was a big call for the British leader. The E.U. is a hugely divisive issue within his Conservative Party and has been for years. By allowing a free vote, Cameron, a leader known for pragmatism, is avoiding possible resignations by senior members of his core team, some of whom are thought to favor leaving the bloc — a position dubbed “Brexit.”

Tourists watch the sun go down behind the houses of Parliament on the river Thames in London, Jan. 5, 2016. (AP Photo/Frank Augstein) (Frank Augstein/AP)

But the move also sets up the awkward scenario of top government ministers campaigning against one another on this vital vote, which many analysts expect will take place this summer.

The stakes are also high for Cameron personally. Analysts say he would come under pressure to resign if he campaigns to stay in the E.U. — as is widely expected — but the majority of Britons vote to leave.

A year ago, the odds of Britain closing the door on the E.U. seemed remote, but as Europe has struggled to cope with a number of crises, including an influx of migrants to the continent, the difference between those wanting to remain part of the bloc and those wanting to leave has narrowed.

Opinion polls show that there is about a 50-50 chance that Britons will choose to cut ties with the E.U.

Cameron told lawmakers that he hoped to finalize a deal with E.U. negotiators on Britain’s demands next month, but he also said he would not rush things if more time were needed.

Some of the demands, notably curbing welfare payments to E.U. migrants living in Britain, have faced fierce resistance from other bloc leaders. They say such a move would violate the freedom of E.U. citizens to live and work in any member state, a core principle of the E.U. project.

Those wanting to leave the 28-nation bloc have cheered the prime minister’s free-vote decision.

“I do applaud it,” Michael Fabricant, a Conservative Party politician and Euro-skeptic, told the BBC. “It would have been far more bloody and far more damaging had he not allowed a free vote.”

Matthew Elliott, who leads the Vote Leave campaign, said in a statement: “We’ve had lots of useful meetings with government ministers and look forward to working with them much more closely now.”

Some critics of Cameron’s decision, including John Major, a former Conservative prime minister who saw his own authority diminished over the issue of Europe, called it a miscalculation and said the government should follow its convention of collective cabinet responsibility.

Political analysts said Cameron had little choice if he wanted to avoid high-profile resignations or damage to cabinet unity on other issues. But there is also a risk that the ensuing debate will leave the party bitterly divided and increase the odds of Britain cutting its ties with the E.U.

“It will make it more likely that Britons will vote to leave the E.U., all other things being equal,” said Tony Travers, a political expert at the London School of Economics. “But the issue is so toxic for the Conservative Party that, from Cameron’s point of view, this is the least worst way forward.”