British Prime Minister Theresa May with President Trump walk along The Colonnade at the White House on Jan. 27. (Christopher Furlong/Getty Images)

President Trump may have just lost the best friend he had in Europe.

British Prime Minister Theresa May emerged from national elections damaged and without the mandate she sought. Her efforts to align with Trump may have hurt her, and she now has less leeway to cooperate with a leader that a majority of Britons recently labeled a threat to international security.

She also has less leverage. May’s Conservatives lost their majority in Parliament in the election Thursday, and she must govern in a coalition — if she keeps her job at all.

Britain’s relationship with the United States was far less important as an election issue than domestic economic and security concerns, but some voters appear to have punished May for cozying up to Trump and elements of his populist agenda.

May is left weaker both in her dealings with Europe and the United States, U.S. and British analysts said.

(Sarah Parnass/The Washington Post)

“With a minority government or a bare majority government, it will be tougher to stand up to Trump. The smaller the majority, the tougher that is,” said Thomas Wright, director of the Brookings Center on the United States and Europe.

“And it will not be her main priority,” he added. “She will be fighting for her own job.”

The Conservatives control 318 seats, more than any other party but just under 49 percent of total seats. May remains prime minister, but there are calls for a Tory leadership shake-up.

For Trump, May’s political tumble represented only the latest blow to his antiglobalist message after his victory last year — along with the Brexit vote in Britain to leave the European Union — appeared to augur a populist wave on both sides of the Atlantic.

Instead, France decisively elected a pro-European Union president last month in Emmanuel Macron, rejecting the nationalist candidacy of Marine Le Pen, whom Trump had supported. And in Germany, longtime Chancellor Angela Merkel, who has been hailed as a bulwark against Trump in support of the traditional liberal order, has in recent months seen her standing rise ahead of her bid for a fourth term this year.

Far from heading up a new transatlantic coalition of nationalist-leaning leaders, Trump finds himself increasingly isolated, as he was on his recent trip to Europe during which Merkel, Macron and others unsuccessfully pressed him to keep the United States in the landmark Paris climate agreement. Trump’s caustic calls on fellow NATO leaders to devote more money to defense spending, on the grounds that the United States has carried an unfair burden, sounded less like a rallying cry to some of his colleagues than a petulant display of hubris.

Trump did not immediately comment Friday on the British election except to call the outcome “surprising” when asked during a photo opportunity in the Oval Office. Trump spoke with May by phone and wished her well, the White House said Friday evening.

President Trump stands with British Prime Minister Theresa May on Jan. 27 in the Oval Office of the White House. (Pablo Martinez Monsivais/AP)

“President Trump emphasized his commitment to the United States-United Kingdom special relationship and underscored that he looks forward to working with the Prime Minister on shared goals and interests in the years to come,” a White House statement said.

Dan Fried, a former State Department assistant secretary for Europe who is now at the Atlantic Council, said there are parallels between this week’s British election and the 2016 U.S. presidential contest. Then, Democratic candidate Hillary Clinton first faced a strong challenge from self-described socialist Sen. Bernie Sanders (I-Vt.) before losing to Republican candidate Trump amid voter anger at the status quo.

“It also means that the U.K., like the United States, might be consumed by domestic politics” in the aftermath of this vote, Fried said. “That is a loss that doesn’t help America at all. Between domestic politics and Brexit, the U.K. has less energy to devote to global issues where we need it.”

Although May publicly disagreed with Trump on some issues during the U.S. election last year, she had rushed to put her relationship with the U.S. leader on good footing with a visit to the White House just days after Trump’s inauguration.

It was a calculation that, despite differences of opinion, Britain must continue to stress rock-solid alliance with the larger, richer and more powerful United States. It now sets her apart from the other two large European players — France and Germany — whose leaders have moved to distance themselves from Trump, at least rhetorically.

May’s principal opponent, left-wing Labour candidate Jeremy Corbyn, was hostile to Trump during the election campaign and cast May as the unpredictable American leader’s toady.

“Waiting to see which way the wind blows in Washington isn’t strong leadership,” Corbyn said last month. “And pandering to an erratic Trump administration will not deliver stability.”

May was ridiculed for holding hands with Trump during an awkward White House stroll, a meme that resurfaced during the campaign as proof that she had been naive.

May appeared reluctant to criticize Trump strongly, even as her political opponents and other European leaders did so. She expressed only muted “disappointment” over Trump’s decision last week to withdraw the United States from the Paris climate accord, and initially declined to criticize Trump directly for his Twitter criticism of London’s mayor.

May later said Trump was “wrong” to criticize London Mayor Sadiq Khan over his handling of terrorist attacks.

Appearing in the Rose Garden outside the White House Friday alongside Romanian President Klaus Iohannis, Trump made clear that he believed his strategy to pressure European partners, in the face of criticism from some of them, was working. He boasted that his efforts had convinced NATO members to contribute more money to collective defense and agree to focus more on counterterrorism efforts.

Trump also affirmed his commitment to Article 5 of the NATO treaty pledging collective defense of the alliance — a step he had pointedly declined to take during his recent trip to Europe.

In Britain, conservatives held a 20-point lead at the start of the two-month campaign, and May called the election early as a way to expand her majority and strengthen her hand going into negotiations with the European Union over terms of Britain’s exit from the Common Market.

The stunning reversal was partly buyers’ remorse over the vote a year ago to take Britain out of the European Union — a move Trump has applauded — and it is now unclear whether May can make the clean break she has promised. Talks begin later this month.

Corbyn’s unexpected successes, however, may show that the current of dissatisfaction with the political status quo remains potent. Young British voters turned out heavily for Corbyn, whose platform had parallels to Sanders’s. Like Trump, however, Corbyn has an isolationist streak and did not always appear to share his party’s opposition to Brexit. As a candidate, Corbyn had promised to try to reset the terms of Britain’s departure.

Last summer, when Clinton was favored to defeat Trump, the Pew Research Center asked Britons how much confidence they had in the Republican candidate.

In that survey, 12 percent said they had at least “some” confidence, while 85 percent had “not too much confidence” or less. Fully 71 percent had “no confidence at all” in Trump.

In February, the Guardian found that 64 percent of Britons said Trump is a threat to international stability and that 56 percent called him untrustworthy.

That was before Trump mocked Khan on Twitter for his reaction to a June 3 terrorist attack that killed civilians on the iconic London Bridge. Khan had told Londoners that terrorists cannot be allowed to win, and that the city would not cower. Khan also said “there’s no reason to be alarmed” by increased police presence in the days after the attack — a statement that Trump mischaracterized.

Londoners have since held demonstrations against Trump and what many perceived as a slight against Khan’s Muslim faith. May and her foreign minister, former London mayor Boris Johnson, have said they will not rescind May’s offer for Trump to make a state visit this year. The visit has not been scheduled.

Emily Guskin in Washington and Isaac Stanley-Becker in London contributed to this report.