Former London mayor Boris Johnson announced he will not run for British prime minister June 30, following Britain’s vote to leave the European Union. (Reuters)

Former London mayor Boris Johnson announced he will not run for British prime minister June 30, following Britain’s vote to leave the European Union. (Reuters)

It was a scene lifted from the scripts of Shakespeare — or perhaps a binge-watching session of “House of Cards.”

When Thursday morning broke, Boris Johnson, the transparently ambitious former mayor of London, was preparing to give the speech of his life — one that would vault him out of the political mayhem wrought by last week’s referendum on the European Union and straight to the job he had long sought: British prime minister.

But the man who was to be Johnson’s campaign manager had a different idea: Michael Gove, the bookish justice secretary who had repeatedly denied any aspiration to higher office, was getting ready to stick a dagger into Johnson’s chances, and twist.

By day’s end, Britain would be reckoning with one more betrayal in a political season full of them. This one stunned an already dazed nation, and left no doubt, if any had remained, that Britain is divided, directionless and leaderless as it prepares for a leap into the unknown of life outside the E.U.

[The mess in British politics, and how to govern in a time of no confidence]

Michael Gove just tore up the script for British politics. He was supposed to throw his support behind former London mayor Boris Johnson, but today said his onetime ally wasn't fit for leadership. (Deirdra O'Regan,Jason Aldag,Karla Adam/The Washington Post)

Johnson, the mop-headed rogue who had been considered the odds-on favorite to take the keys to 10 Downing Street, has now been shunted to the sidelines of the contest to lead the Conservative Party and, by extension, the nation.

In his place, Gove will vie with Theresa May, the no-nonsense domestic security chief, for the privilege of running a country in the midst of an existential crisis. The current prime minister, David Cameron, has said he will step down by Sept. 9 after losing the campaign for Britain to remain in the E.U.

The narrowing of the field of likely winners to Gove and May leaves behind two candidates who are expected to drive an especially hard bargain with the E.U., meaning the country could be in for years of contentious and costly negotiations no matter who emerges as leader.

Johnson had been seen as a possibly more pliant figure in those talks: Although he was the face of the campaign for “leave,” most observers thought he took that stand less from a sense of ideological conviction than from a barely concealed well of political opportunism.

In the days since the vote, he had begun to walk back the promises of Brexit, signaling he would fold easily on immigration — the “leave” campaign’s signature issue.

[Michael Gove just turned British politics into a ‘House of Cards’ episode]

It may have been that malleability that prompted Gove, a Brexit true believer and the campaign’s intellectual architect, to undercut his ally. Or perhaps it was just Johnson’s legendary disorganization.

View Graphic Meet the European leaders hoping to cause the next Brexit

Either way, Gove struck like a bolt from the blue: Less than three hours before Johnson was to declare his candidacy, Gove emailed a statement declaring that he had come “to the conclusion that Boris cannot provide the leadership or build the team for the task ahead.”

Instead, Gove wrote, he would run for prime minister himself.

Gove, who has been nearly invisible since last Thursday’s vote, did not release any detailed vision for the country’s future, which he said would be unveiled “in the coming days.”

But the split in the pro-Brexit camp brought an immediate stampede of defections, with Johnson supporters abandoning their candidate in favor of a man who had been unceremoniously demoted to chief whip less than two years ago and who had long insisted he was temperamentally unsuited for Britain’s top job.

Later in the morning, with the clock ticking down on a noon deadline to enter the fray, Johnson broke his silence with a speech that had all the makings of a campaign kickoff.

[London mayor begins own autonomy push]

He boasted of his achievements as London mayor and laid out a vision for making Britain a fairer and more prosperous society outside the E.U.

His supporters applauded lustily. But when Johnson came to what he called “the punchline,” he unleashed a stunner, saying that the country needed a leader to take it in a new direction but that “I have concluded that person cannot be me.”

The words brought tears to the eyes of his backers. But they also brought incredulity from critics, who wondered how he could simply walk away.

“Boris engineered the largest constitutional crisis in postwar history but won’t even put his name forward to clear it up?” tweeted University of Manchester political scientist Rob Ford.

Gove’s decision to ambush Johnson also brought immediate recriminations from both men’s corners. Asked by the BBC about Gove, Johnson’s father, Stanley Johnson, replied: “ ‘Et tu, Brute’ is my comment on that.”

Gove backer Dominic Raab told the network that Johnson had been “cavalier” in his approach to the campaign. “We’re picking a prime minister here to lead the country, not a school prefect,” he said acidly.

[Boris Johnson says the darndest things]

Gove’s turning on Johnson is just the latest in a string of betrayals at the highest reaches of British politics. Earlier this year, Johnson and Gove spurned Cameron, their friend and sparring partner since their days at Oxford, by campaigning for “leave.”

As the pro-Brexit camp splintered Thursday, May presented herself as a unifying candidate for prime minister who, despite backing “remain,” could bring together the badly fractured Conservative Party.

She was introduced Thursday by Chris Grayling, a prominent Brexiteer, and described herself as the candidate best prepared for the tough talks ahead with E.U. leaders, having spent years wrangling with other European security chiefs as the country’s home affairs minister.

“I have not just done it. I’ve delivered on those negotiations,” she said.

Despite supporting “remain,” May said there would be no going back.

“Brexit means Brexit,” she said. “The country voted to leave the European Union, and it is the duty of the government and of Parliament to make sure we do just that.”

[Europe’s remaining leaders meet to safeguard fractured union]

May was considered only a reluctant E.U. backer, with a long record of Euroskepticism and a hard line against mass immigration.

May would be the second female prime minister in British history, after Margaret Thatcher. May’s unsmiling public persona and hard-line conservative politics have drawn occasional comparisons to the Iron Lady.

Britain’s next prime minister will not be picked by the public. Instead, he or she will be selected in a two-stage process within the governing Conservative Party. First, the party’s members of Parliament will whittle the field down to two over the next two weeks. Then the party’s rank-and-file members will select the winner.

In addition to Gove and May, three other candidates were nominated Thursday: Stephen Crabb, Liam Fox and Andrea Leadsom. All are considered long shots.

[Brexit, illustrated]

Cameron has said he will not formally trigger Britain’s exit and will leave that task to his successor. Once that happens, the next prime minister will have two years to negotiate a new deal with the E.U.’s 27 remaining members.

Europe has already signaled that it will refuse to budge on likely British demands that the bloc relax its rules requiring freedom of movement for workers across national borders. European leaders say that if Britain wants access to the single market, it will have to accept free movement.

As the political winds shifted throughout Thursday, the pound swung between gains and losses. Overall it is down about 10 percent against the dollar compared with where it was before the referendum.

While the pound has taken a hit, stock markets on both sides of the Atlantic have bounced back quickly after steep declines last week. The FTSE 100, a key index on the London Stock Exchange, climbed 2.27 percent Thursday and has reclaimed all its losses since Brexit. So have U.S. markets.

[Brexit leader mocked E.U. by saying its lawmakers never had ‘proper’ jobs. He’s wrong.]

Britain’s political unrest has not been limited to the Conservatives.

The internal warfare among Tories has been matched — and even exceeded — within the opposition Labour Party.

Pressure continued to build Thursday on party leader Jeremy Corbyn to resign after what was seen as an ambivalent effort to rally party supporters to the pro-E.U. cause.

He has already suffered an overwhelming vote of no confidence among his Labour colleagues in Parliament, and he faced more defections Thursday. Plans to mount a formal challenge, however, were put on hold because mutinous members suggested they did not want to compete with news coverage of Thursday’s meltdown across the aisle.

Even by the occasionally bloody standards of British political history, the past week has been especially laced with treachery.

“You couldn’t make it up,” Tory member of Parliament Nigel Evans told the BBC. “It makes the ‘House of Cards’ look like ‘Teletubbies.’ ”

Brian Murphy in Washington contributed to this report.

Read more:

Britain confronts a wave of racist incidents after the Brexit vote

Brexit leaders walk back some of their biggest promises

Brexit prompts a push to end English in the European Union

Today’s coverage from Post correspondents around the world