He said Londoners were open to the world. “The reason why London is the greatest city in the world — and it is — we have never taken an isolationist approach,” Mr. Khan said. “We are open-minded. We are outward-looking. We embrace other cultures and learn from other cultures and ideas as well.”

Mr. Khan also called for a more positive campaign in favor of remaining in the union — both campaigns have been pressing on voter anxiety, either about economic risks of leaving or the dangers of supposedly uncontrolled immigration if Britain stays in.

So on Monday, he and Mr. Cameron unveiled a pledge card that will be distributed around the country in the name of the Remain campaign, making voters five guarantees: full access to the European single market, protection of workers’ rights, the continued right to issue arrest warrants in Europe, a special status for Britain in Europe and economic stability.

Mr. Cameron’s problem is not with the Labour Party but with his own Conservatives, who are deeply divided over Europe. To pacify them, and to undermine the populist U.K. Independence Party, or UKIP, he promised this referendum if he won a second term in elections a year ago.

Now he is stuck with it, and the complexities of Britain’s long relationship with the European Union and the difficulties of extracting Britain are nearly impossible to explain to political scientists, let alone ordinary voters, for whom Europe had never been a particularly prominent issue.

Seeming to trail among voters, those favoring exit, or Brexit, have been pushing UKIP’s line about controlling immigration as the issue most likely to motivate voters. On Sunday, Mr. Johnson and Michael Gove, the justice minister and another leader of the Leave campaign, wrote a letter to Mr. Cameron accusing him of “corroding public trust” by promising in vain to limit net immigration to fewer than 100,000 a year.

Official statistics showed last week that net migration to Britain from the European Union alone last year was 184,000 out of a total of about 330,000. Brexiteers argue that Britain can control immigration only by quitting the bloc, which requires freedom of movement and labor for all European Union citizens.

The letter was taken as a direct challenge to Mr. Cameron’s authority, and this vote will also define how long he remains in office. Anything less than a solid victory for Remain could bring a hasty end to his political career, and the bitterness of the fight will make it hard for the party to reunite no matter the result.