The British electorate delivered another surprise Thursday, and the shock waves from the victory for British Prime Minister Boris Johnson and his Conservative Party are being felt far beyond the United Kingdom. Though the analogies are imperfect, what happened there has implications elsewhere, including the United States as it heads toward the election of 2020.

The vote showed the widening gap between urban and nonurban areas of Britain and the reshaping of the party coalitions — a pattern that is familiar in the United States in the era of President Trump. The results underscored, in a related way, the disdain many of those nonurban voters have for the elites as well as the power of a nationalist message, something else that has affected American politics.

The rout suffered by the Labour Party and its leader, Jeremy Corbyn, also provided a clear warning of the limits of a left-wing agenda, though Corbyn is more left wing than any of the Democrats running for U.S. president and was saddled with stains of anti-Semitism. Nonetheless, Labour’s defeat — its fourth election loss in a row and its worst performance since 1935 — could influence the thinking of many Democratic U.S. voters as they pick a nominee next year.

Johnson started off badly, with one of the worst opening acts of any modern British prime minister, losing big votes in Parliament and seemingly stumbling toward disaster and a possible early ouster. But the wily Johnson did what his two Conservative predecessors failed to do and emerged Friday morning with the biggest Tory victory since 1987 and the days of Margaret Thatcher.

His predecessors in 10 Downing Street, David Cameron and Theresa May, both made huge political bets and lost. Cameron called the Brexit referendum in 2016, fully expecting that voters would support remaining in the European Union and hoping that would dampen the long-standing divisions in his party over Europe. When the opposite happened, he stepped down immediately.

Cameron was succeeded by May, whose political skills were no match for the challenge she had been handed by Cameron. As she wrestled with opposition at home to her negotiations with the E.U., she made a fateful decision by calling a snap election in 2017. She hoped the election would add to her narrow parliamentary majority. Instead, the election cost her that majority. She never fully recovered, eventually stepping down because of the impasse over Brexit and her inability to maneuver through.

Johnson made an equally bold bet and won handsomely. Faced with the impasse over the terms of fulfilling the vote to leave the E.U., he, too, called for an election. When Corbyn and Labour finally agreed to that, the die was cast. British voters faced a choice familiar to Americans in 2016, picking between two unpopular leaders of the major parties.

The Tories began the election with a solid lead, but late polls showed the gap between Conservatives and Labour narrowing, which only added to the drama when the exit polls posted as the polls closed showed Johnson’s party headed toward a huge victory.

British politics in the Brexit era have become more complex because of the way the issue has scrambled coalitions. There is a traditional left-right division — Conservatives vs. Labour — but there is also a Brexit division that has split the coalitions of both major parties. Through the past few years, Brexit did more to bedevil the Conservative Party, which was torn between those strongly in favor of leaving the E.U. even without an agreement and those wary of taking that step.

On Thursday, Brexit bit into the Labour coalition and bit hard. The Labour Party suffered devastation in working-class areas of the country outside of London, areas that had been voting for the party for generations. Among those that went from Labour to Conservative was the mining district once represented in Parliament by Tony Blair, a former prime minister.

These were districts where voters had supported the Brexit referendum, and these voters finally showed their frustrations by giving Johnson a handsome majority and the power now to begin the initial step of taking Britain out of the E.U. and into an uncertain future.

A similar thing has been happening in this country as party coalitions undergo changes. Although Democrats have long claimed to be the party of the white working class, that’s hardly the case anymore. For many years, working-class whites have been moving toward the Republican Party, and under Trump that movement has accelerated. That’s the conundrum facing Democrats as they think about how to assemble an electoral college majority in 2020.

The exhaustion factor may have contributed to the results in those areas in Britain that abandoned Labour for the Conservative Party. After nearly four years of wrangling over how to exit the E.U., many voters may have decided that only by giving Johnson a freer hand could the country get past this gridlock in Parliament, whatever the consequences.

In the United States, the exhaustion factor could cut differently — exhaustion caused by the volatility and chaos sown constantly by Trump. Democrats are hoping that will help motivate voters on the fence to back their nominee and limit Trump’s presidency to a single term.

But there could be more to what happened in Britain than simply a fatigue with Brexit. The swings could be related to Brexit, but some party leaders might be refusing to acknowledge reality. The defections also could reflect fears that the Labour Party no longer truly represents the interests of people living in outlying areas of Britain, that the cultural disaffection of those voters — who have suffered long-term economic decline — has led to a new voting pattern.

Corbyn is a special case, given his long history and record. But only a few years ago, when Labour did better than expected in the election, he was seen as a possible, if still implausible, prime minister. On Thursday, the roof caved in on him. He said he would not stand for another election as party leader.

Some veterans of Labour politics think the vote reflected Corbyn more than Brexit, sensing that Corbyn and his tight band of supporters repelled voters and cost the party enormously. The Labour Party now faces a period of bloodletting and internal turmoil over the way toward a post-Corbyn party.

That will pit Labour’s left against the center, a more virulent strain of the debate already underway in America’s Democratic Party. Some people have suggested that Corbyn’s defeat is a warning to Democrats that Sens. Bernie Sanders (I-Vt.) or Elizabeth Warren (D-Mass.) could deliver the same fate if they become the party’s nominee. Neither carries the baggage that Corbyn was carrying, but the British election will add to the pressures on those two candidates to dissuade voters that they would be too risky in facing Trump in a general election.

It cannot be overstated that Brexit is its own case and has paralyzed British politics since the referendum, but there are perils in suggesting it has no relevance to politics elsewhere. The urge to leave the E.U. is in part a reflection of the nationalist strain that exists elsewhere. In the United States, Trump has given it a name: “America First.” His base has responded to that message, and he is counting on it as a motivating factor in November.

Johnson began this election in better shape than Trump is in as he looks to next year, despite the prime minister’s own unpopularity and limitations. Still, Johnson’s ability to produce sizable margins in so many of the nonurban districts stands as a possible template for the Trump campaign.

Whether the president has reached the upper limit of turnout in his strongest voting blocs or has more votes to pull is unanswerable today, though his campaign clearly believes there are more to gain. Democrats can’t assume that won’t happen.

The results in Britain are likely to intensify the debate among Democrats over both the party’s agenda and its path to victory. Can Democrats really win back working-class voters, and, if so, how? Or should they bank on returns from the 2018 midterms and subsequent elections that have shown the power of the suburban vote as a foundation of the party’s emerging coalition?

Reading too much into what happened Thursday in Britain is risky. But so, too, is dismissing those results as of no relevance to politics here.