By the time that Jeremy Corbyn, the leader of the Labour Party in the United Kingdom, arrived at the vote count in his Islington North constituency, in the small hours of Friday morning, it was clear that something historic had taken place in British politics. Thursday’s snap general election, which Theresa May, the Conservative Prime Minister, had called to bolster her party’s slim minority in the House of Commons, had turned into something of a calamity for her party and a humiliation for her personally. The outcome was also a stunning vindication for Corbyn, who had defied the predictions—some of them offered by his own colleagues at Westminster—that he would lead the Labour Party to a crushing defeat.

On Thursday, after the polls closed at 10 P.M., a network exit poll projected that the Conservative Party, far from improving its position in the Commons, would fail to gain an over-all majority–an outcome that virtually nobody predicted a month ago. As the results filtered in from around the country, they confirmed the exit-poll projection. On Friday, with all but one of the six hundred and fifty seats in the House of Commons accounted for, the Conservatives were projected to win three hundred and eighteen seats—thirteen fewer than the Party won in the 2015 general election, and eight votes shy of a majority. Labour won two hundred and sixty-one votes, a gain of twenty-nine. Later on Friday, May said that she would form a new government with the support of the Democratic Unionist Party in Northern Ireland, which won ten seats. But there was a lot of speculation about a possible leadership challenge to her in the Conservative Party, and even talk of another election sometime soon.

Corbyn kept his own seat, which he has held since 1983, by a record majority—a fact he pointed out in his acceptance speech. He also thanked the police for the work they have done over the past couple of weeks, which have seen two deadly terrorist attacks, in Manchester and London. Then he gave his owns analysis of the election outcome. “You know what?” he said. “Politics has changed, and politics isn’t going back into the box where it was before.”

“Because what’s happened is people have said they have had quite enough of austerity politics,” he went on. “They have had quite enough of cuts in public expenditure, underfunding our health service, underfunding our schools and our education service, and not giving our young people the chance they deserve in our society. . . . And I’m very proud of the results that are coming in all over the country tonight, of people voting for hope, voting for hope for the future and turning their backs on austerity.”

Corbyn, who also called on May to resign, had ample grounds for celebrating. Labour entered the six-week election campaign trailing by twenty points or more in opinion polls. On Thursday, according to the BBC’s vote tally, Corbyn’s party came within 2.4 percentage points of matching the Tory vote share of 42.4 per cent, which suggests that an unprecedented swing took place during the campaign.

In many different parts of the U.K., Labour exceeded expectations. In northern England, May had targeted Labour's traditional working-class base with promises of restrictions on immigration and a “hard” break from the European Union. But Labour held onto most of its seats in the region, and even picked some up, such as in Leeds North West and Warrington South. In Scotland, Labour made up some of the ground it lost to the Scottish National Party in 2015. In Greater London, Labour picked up three seats from the Conservatives, as many affluent pro-E.U. voters turned against the government. (One seat in London, South Kensington, is still too close to call.) And in other bits of southern England, it won in places that had long been considered parts of the Tory heartland, such as Canterbury.

How did it happen? Corbyn ran in opposition to the Conservatives’ long-standing austerity policies, and after years of being told that there was no alternative to shutting down libraries, cutting benefits, raising tuition fees, and starving public projects of investment, large sections of the British public apparently had simply had enough. In its election platform, Labour promised to spend more on the health service, schools, higher education, and care for the elderly. The Party said that it would raise the extra money by increasing taxes on rich households and big corporations. Labour also pledged to bring the water-supply industry and the railways, which are very unpopular, into public ownership.

But there was more to the result than voters rejecting the economic legacy of George Osborne, the former Chancellor of the Exchequer, and David Cameron, the former Prime Minister—though such a rejection was important and welcome. By design or good fortune, Corbyn and his Labour colleagues also managed to turn the Brexit debate to their advantage. In 2015, the Labour Party, which was pro-E.U., lost a significant number of its working-class voters to the U.K. Independence Party, which held anti-E.U. and anti-immigrant positions. In calling an early election this year, May was betting that many of these same people would vote Conservative this time. The plan didn't work out.

Last year, after the Brexit vote, Corbyn publicly accepted the result of the referendum—against the wishes of some Europhile Labour M.P.s—and said that Labour, which had long championed European integration, would seek to restrict the movement of workers across borders. But Corbyn also pledged to pursue a “soft Brexit,” and stressed the importance of continued access to the European single market, thus distancing himself from May, who is committed to a “hard Brexit” that could see Britain crashing out of the E.U. with no exit agreement at all. “What is remarkable about Corbyn's achievement is that he is getting Remain votes in London, and he's getting UKIP voters in the rest of the country,” Nigel Farage, the former leader of UKIP, who is no fan of Corbyn, noted in admiration as the vote tallies came in. “He kind of boxed off Brexit as an issue for UKIP voters.”

Farage also complimented Corbyn's campaigning skills, saying, “He looked comfortable in his skin. He seemed to be enjoying himself. The Prime Minister came across as insincere, and frankly robotic.” Certainly, May, if she is forced to resign, will have played a large part in her own downfall. By calling a third national vote in three years, she irked many voters and portrayed herself as an opportunist. By constantly falling back on stilted sound bites, she failed to give the voters much of a positive reason to vote Conservative. And by refusing to debate with Corbyn and the other Party leaders, she gave the impression that she was trying to hide. (What role was played by her awkward embrace of Donald Trump, who is extremely unpopular in Britain, it is hard to say, but it certainly didn't help matters.)

Corbyn, by contrast, dived into the campaign. As I noted a few days ago, there were echoes of Bernie Sanders's insurgent Presidential campaign in Corbyn’s approach. To circumvent a largely hostile print media, he relied on social media and television appearances. That didn't prevent the Tory newspapers from trying to smear him. On the day before the election, the Sun's front-page headline was “JEZZA'S JIHADI COMRADES.” The Daily Mail ran a front-page photograph of Corbyn and two of his close colleagues under the headline “APOLOGISTS FOR TERROR.”