When Prime Minister David Cameron told the public he had negotiated a deal on EU reforms in February, he said Britain would be "stronger, safer and better off inside a reformed European Union."
As he announced plans for Thursday's in-out referendum, Cameron said he could secure a "special status" for Britain and urged voters to back him in "one of the biggest decisions we will face in our lifetime."
Cameron, Chancellor George Osborne and other members of the Conservatives' Remain campaign have tried to hammer home their message that leaving the EU would destroy Britain's economy for the foreseeable future, pleading with them not to "take a leap in the dark."
The opposing side accused Cameron of leading a "project fear" but it struggled to counter his economic arguments. The Brexiters, especially the UK Independence Party (UKIP), have intensified a focus on EU freedom of movement, which is seen by many British people as part of a highly divisive wider debate on immigration.
But until the last few weeks, pro-Remain politicians had largely dismissed or ignored the concerns raised by UKIP leader Nigel Farage and more recently by the Vote Leave campaign, which is spearheaded by ministers from Cameron's Conservative Party.
Neither side is expected to win a resounding victory in the referendum, meaning there is likely to be a further push for EU reforms or even a second referendum from Leave supporters if Remain wins. Immigration seems certain to remain a major cause of division.
On June 10, pro-Remain Labour lawmaker Jo Cox wrote an article for regional newspaper The Yorkshire Post, reassuring voters that it was "fine to be concerned about immigration."
Worries about immigration do not mean people are "racist or xenophobic – they are simply concerned about pressures on GP (doctors') surgeries or schools, or how once familiar town centres are changing, or whether they'll be able to compete with migrant workers to get a job," wrote Cox, who was murdered six days later in her constituency in Birstall, West Yorkshire.
Cox had echoed Labour's leaders in countering a surge of propaganda against EU migration by Leave campaigners, amid concerns that support for a Brexit was building in northern English areas like West Yorkshire.
Vote Leave distributed a leaflet to British homes in the final weeks of campaigning, setting out a list of "facts" about the country's relationship with the EU. The first fact was that "over a quarter of a million people migrate to the UK from the EU every year. This is the equivalent of a city the size of Newcastle."
After Cox's death on June 16, a 52-year-old local man with a history of mental illness was charged with her murder.
When asked by a court to confirm his name, Tommy Mair replied: "Death to traitors, freedom for Britain." Mair, who is accused of stabbing and shooting Cox, was praised by several right-wing extremists on social media.
Cox's death prompted a suspension of referendum campaigning. It appears to have encouraged more measured rhetoric after many politicians and analysts warned that the language on both sides had become too extreme.
Cameron broadened his earlier economic focus in an appeal on Sunday for voters to choose a "liberal, tolerant Britain."
Pro-Remain Scottish National Party leader Nicola Sturgeon said she hoped the country "can have a debate that doesn't focus on immigration" in the final few days before the referendum.
Rather than trying to limit migration, the government should "deal with the impact," Sturgeon told Sky News on Sunday. "Let's invest in housing and public services rather than blame immigrants or take a view that we should somehow close our borders," she said.
Speaking in parliament on June 15, Cameron said his government was committed to creating a "controlled migration fund" that would assist areas with high numbers of recent migrants.
If he wins the referendum, he will need to make good on that promise, both to placate colleagues on the right of his own party and perhaps to go some way to appeasing voters angered by his failure to fulfil last year's election pledge to cut annual net migration to below 100,000.