Jeremy Corbyn’s opposition Labour Party may have come in second in the British election on Thursday, but the results amount to a stunning triumph for a far-left leader who many believed was headed for political oblivion.

Official results showed Labour gaining seats as the Conservatives fought to maintain a majority. The outcome was a testament to Corbyn’s remarkable campaign, which turned around expectations that Theresa May, the Conservative prime minister, would demolish his party.

As of 5 a.m., a projection based on official results for the majority of districts put the Conservatives in first place, with 318 seats in the 650-member Parliament, but indicated that May’s party would fail to win a majority. Labour was forecast to win 262 seats, a gain of dozens of seats.

Speaking early Friday in north London, Corbyn proclaimed a sea change in British politics, saying people were “voting for hope for the future and turning their backs on austerity.”

(Amber Ferguson,Sarah Parnass,Jason Aldag/The Washington Post)

May, he said, called the election “to assert her authority” but found only “lost Conservative seats, lost votes, lost support and lost confidence.”

“I would have thought that’s enough to go, actually,” Corbyn said. May, however, showed no sign she intended to step down.

Because Labour was preparing for a crushing defeat, the outcome suggested by early returns will be cast by Corbyn’s supporters as a clear victory for the embattled leader and the leftist ideas he champions. The election result may paradoxically be seen as Labour’s death knell by those who want a new direction for a party that has not won a general election in 12 years. 

“What the early results mean is that Corbyn has got more life in him than anybody might have thought,” said Steven Fielding, a political historian at the University of Nottingham and an expert on the Labour Party. 

“He’s lost, but it means that he’s probably safe from an immediate effort to get rid of him. It’s Theresa May who now has no capital with her party.”

James Morris, a pollster who used to work for Labour, said after the results of an early exit poll was announced that the party’s performance was a result of Corbyn’s “disciplined populism.” 

“Labour went into the campaign 20 points behind and, if this exit poll is borne out, [will] finish it gaining ground on the last election and with a chance of forming the government,” Morris said.

Before he won an upset leadership victory two years ago, Corbyn, 68, had spent three decades as a rebellious rank-and-file lawmaker. His political roots lie in the labor movement and the national campaign against nuclear weapons. 

He promised to deliver “socialism of the 21st century,” including such goals as nationalizing the rail service, pumping billions into the National Health Service and raising taxes on the rich.

Corbyn’s vision is a far cry from that of past leaders like Tony Blair, who won three general elections but ultimately moved the party away from its working-class base and in a more moderate direction. 

In the mold of Bernie Sanders, the Vermont independent who mounted an insurgent bid for the 2016 Democratic presidential nomination, Corbyn sought to harness the forces of populism from the left. 

He also capitalized on fresh doubts about May, who seemed untouchable seven weeks ago when she called the election in a bid to strengthen her majority ahead of negotiations over Britain’s departure from the European Union. She faltered as the race came to a close this week, her poll numbers dropping as Britain suffered its third serious terrorist attack in as many months. 

Meanwhile, Corbyn began the campaign with historically low favorability numbers. A punching bag of the British tabloids, the far-left firebrand has been dogged by charges that he is sympathetic to militant groups, such as the Irish Republican Army, which played into widespread unease about his steadiness and judgment. 

But he rose in the polls as May was forced to reverse herself on central campaign promises, such as a plan to make major changes to how the elderly pay for their social benefits. Meanwhile, Corbyn proved effective on the stump, and tapped into the enthusiasm of youth. 

“People thought he was useless, incompetent and extremist,” said John Curtice, a leading British pollster. “He ends up turning out a better manifesto than the Conservatives, and he can campaign well enough. Those who are not unsympathetic to the Labour Party have said he’s not so bad after all.”

Still, many voters were wary about handing him the premiership in a singular moment for Britain, as it prepares to cut itself loose from Europe.

During a stop in Watford, a commuter town north of London, on the final day of campaigning, Corbyn hardly mentioned Brexit, instead casting the election as a choice about whether the state would lift up the vulnerable.

“What would this country look like with another five years of Tory government?” he said, describing longer lines at hospitals and larger groups of people shut out of housing. 

He jeered at predictions that the campaign would be a “walkover,” saying, “People underestimate the common sense of ordinary people in this country.” 

Sue Utting, 70, labeled herself a “Blairite,” and admitted her concerns about Corbyn’s electability, but said he had won her over. 

Corbyn was not just teeing off against May. He was just as much seeking to quiet voices of dissent within his own party, which has been torn by parliamentary infighting.

After the Brexit campaign last year, in which Corbyn mounted a lackluster defense of European integration, party members passed a vote of no confidence in him. About two-thirds of his party cabinet resigned, as the leader aimed to stamp out a coup. Names of alternative leaders circulated. 

Corbyn was later reelected as leader with the support of the party’s broader membership, reflecting a split between party officials and the base. 

Whereas the election once seem destined to be Corbyn’s wake-up call, it instead may force his critics to regroup.

“I would be pessimistic about anybody’s chances of getting rid of Jeremy Corbyn,” said a former senior Labour aide, who asked not to be identified to speak candidly about internal party matters. 

And analysts said Corbyn’s opponents, as much as they quietly insist they could have won the election with a different leader, do not have a clear strategy to replace him, making such an outcome unlikely.

Because Labour’s manifesto energized its voters — the young in particular — the party is not likely to change course on a policy level, said James Tilley, a political sociologist at the University of Oxford and a co-author of “The New Politics of Class: The Political Exclusion of the British Working Class.” Many of Labour’s progressive promises are indeed popular, he said, and the opposition party is poised to make up ground if the Conservatives stumble in Brexit negotiations. 

Still, he said, there are longer-term challenges, foremost in maintaining the party’s unruly coalition — ethnic minorities, young people, pockets of the working class and educated, middle-class professionals.