LONDON — For more than two years, British Prime Minister Theresa May has been looking for a pair of exit ramps — one to successfully navigate her country out of the European Union, as called for by voters in a 2016 referendum, and another to avoid further damage to her deeply divided Conservative Party. The coming days will determine whether the damage to herself is irreparable.

The prime minister was dealt a terrible hand by her predecessor, David Cameron. It was Cameron’s decision to call the Brexit referendum in the first place, hoping — and perhaps believing — that it would once and for all quiet the anti-Europe wing of his party. It proved a spectacularly failed gamble.

Unexpectedly, the referendum measure narrowly passed, a crushing blow to a political establishment that had lined up almost uniformly in favor of remaining. It also foreshadowed a political revolt by anti-elitist voters that hit the United States a few months later with the election of Donald Trump as president.

And as Britain nears the March 29 deadline for leaving the E.U., Trump continues to undermine the already weakened prime minister as he wages his ongoing campaign against elites.

Immediately after the Brexit referendum, Cameron resigned as prime minister and May won the leadership battle to succeed him. It has turned into a hollow victory that has left her as the prime minister with the single largest defeat on a resolution in the history of Parliament, another defeat nearly as big, a party that is a shambles, an E.U. leadership that has lost its patience, a country exhausted and on edge, a dysfunctional political system, and her future as head of government now measured in months rather than years.

May is not solely responsible for the condition in which Britain now finds itself: She has been hamstrung by hard-liners in her party who have so far made consensus impossible. But as the leader of the country and her party, she has focused more on maintaining unity in that party (or trying to bring it about) rather than pursuing another strategy.

In a political system fragmented and deeply polarized, there is for May clear risk in reaching across the aisle to secure a majority. Adding to the instability is the fact that Jeremy Corbyn, the Labour Party leader, remains stubbornly resistant to stating clearly whether he favors remaining or leaving the E.U. He dodged repeated questions during a Sky News interview Sunday, refusing to provide a simple yes or no to the basic question of the day.

May has absorbed the criticism from all sides. She is pummeled on editorial pages and by members of her own party, even her own cabinet. In other times, her government probably would have fallen. Still she has soldiered on, unwilling to admit ultimate defeat, unwilling to step aside, constantly scratching and clawing for more time and more tweaks to an exit agreement in the hope of gaining a majority vote before the deadline.

This week alone, the degree to which she has painted herself into a corner has become more vividly clear than ever. On the one hand, she is handcuffed by a ruling by John Bercow, the colorful and independent-minded speaker of the House of Commons, who said Monday that she cannot bring the exit agreement back for a third vote without substantial changes. She had planned to try that third vote Tuesday. Now it’s not clear when that will happen.

Bercow’s decision means May is also again at the mercy of the leaders of the E.U. as she begs for a three-month extension to avert Britain crashing out of the union without any agreement and therefore into a future set of arrangements that no one can fully anticipate, let alone explain. The reverberations would be felt widely, in Britain and elsewhere in Europe, with complex supply chains disrupted in ways few can predict and the economic damage unpredictable.

A divided Parliament voted recently against leaving the E.U. without an exit agreement — a “hard” Brexit — even though the prime minister has been unable to command a majority for any such exit agreement. Members of Parliament who sought to take over the issue failed in that attempt. Simply put, things are a total mess. May, meanwhile, clung to the belief that with her agreement, the third time with Parliament will be a charm.

May spent the weekend wooing members of Northern Ireland’s Democratic Unionist Party, in the hope that support from that small bloc would in turn create a domino effect that would bring along the hard-liners in her party (and perhaps some others) in numbers enough to command a majority. Then Bercow dropped his bombshell, and she has been forced to scramble anew.

E.U. officials sound in no hurry to grant May’s request for an extension — and indicated for now that they would do so only if May can prove she has enough votes to win approval in Parliament. That means nothing will happen on the delay request until sometime next week, putting Britain on the brink days ahead of the deadline.

On Wednesday evening, May spoke to the public in a brief televised address. She cast the coming showdown as the people vs. Parliament and put herself on the side of the people who had voted to leave the E.U., ruling out a longer extension or a second referendum.

“You’re tired of the infighting, and you’re tired of the procedural rows. . . . You want this stage of the Brexit process to be over and done with,” she said. “I agree. I am on your side.” But she reiterated that she will not seek an extension beyond June 30. She will learn next week whether she swayed enough votes.

Into all this confusion have leaped President Trump and his eldest son, Donald Trump Jr., though in ways that only add to the muddle. The president last week told reporters at an Oval Office photo op that he had given May advice long ago and she had ignored it. He claimed his advice would have led to a successful exit for Britain. “She didn’t listen to that, and that’s fine,” he said.

His son published a far more incendiary opinion piece in Wednesday’s editions of the Telegraph. The article was a battle cry in behalf of the forces that elected his father and upended Britain with the Brexit referendum. He disparaged May for ignoring his father’s advice (May has said Trump told her to sue the E.U.) and called on her to live up to the results of the referendum and take Britain out of the E.U. quickly, while warning that a reckoning is coming on both sides of the Atlantic.

“Brexit is an example of how the establishment elites try to subvert the will of the people when they’re given the chance,” Trump Jr. wrote. “Here in the United States, we’ve seen similar efforts to overturn legitimate election results.”

To the president’s son, the villains are the bureaucrats at E.U. headquarters in Brussels blocking Britain from leaving the union (news to those leaders, who blame May for not finding consensus in her country on how to leave) and “the Democrats and deep state operatives” out to frustrate his father and block his agenda.

“What we’re seeing now in Washington, London and Brussels is the desperate, last-gasp attempt by those previously in power to cling on to what was once theirs in the face of an overwhelming mandate for change,” he wrote.

Neither Donald Trump nor the pro-Brexit forces won overwhelming mandates, however. They prevailed but narrowly. The Brexit vote margin was four points. Trump’s electoral college majority was comfortable — but it was secured by victories in three crucial states by a total of fewer than 80,000 votes — and he lost the popular vote.

The aftershocks of 2016 continue on both sides of the Atlantic. In both Britain and the United States, the battles are not over, and they probably won’t be for some time to come.