LONDON — In a day of intrigue and betrayal, predictions about the next prime minister of Britain were overturned on Thursday as the presumed favorite, Boris Johnson, said he would not run after his ally in the Brexit campaign, Michael Gove, suddenly announced his candidacy.

Mr. Gove had once ruled himself out for the job. His U-turn Thursday wrecked Mr. Johnson’s prospects and enhanced those of Theresa May, the home secretary, who had backed the Remain campaign but with little enthusiasm.

With Mr. Johnson out, the prospect of a race between Ms. May, 59, and Mr. Gove, 48, the justice secretary, also indicated that the next prime minister would not seek to keep Britain in the duty-free single market of the European Union if the price was no restriction on immigration from the bloc.

The sense that Mr. Johnson, the former London mayor, might try to reach a softer deal with Brussels, and his unwillingness to promise key jobs to Mr. Gove and other leaders of the campaign to exit the European Union, helped doom his candidacy, legislators said.