LONDON — British Prime Minister Theresa May told members of her party on Wednesday evening that she was prepared to step down if they voted to support her contentious Brexit deal.

Her offer to resign came after months of chaos in Parliament and speculation that she would be forced out.

Another moment of high drama in the Brexit process, May's move was a last-ditch effort to pass her deal to leave the European Union nearly three years after voters approved doing so in a June 2016 referendum.

"I have heard very clearly the mood of the parliamentary party," the prime minister told a closed meeting of her own lawmakers, according to a government statement released afterward. "I know there is a desire for a new approach — and new leadership — in the second phase of the Brexit negotiations, and I won't stand in the way of that."

She added, "I am prepared to leave this job earlier than I intended in order to do what is right for our country and our party."

However, hours after the prime minister's offer, the Democratic Unionist Party, who have acted as kingmakers for May's minority government, signaled they would not support the Brexit withdrawal agreement that she has painstakingly negotiated with the E.U.

This raises serious questions about whether the prime minister can force through her deal — even if she manages to get all her own lawmakers onside.

Adding to the sense of chaos swirling around the Palace of Westminster, Members of Parliament also rejected eight other alternatives to the prime minister's deal. One of the closest non-binding motions — designed to test whether there is an option lawmakers will support — was the one backing a second referendum, which lost by just 27 votes.

May's deal has already been crushed twice in the House of Commons — suffering the heaviest and fourth-heaviest losses in parliamentary history.

To reverse this, May would need to flip most if not all of the 75 Conservative lawmakers who previously opposed the deal. She would also need the support of the Northern Irish DUP, who oppose May's deal because they fear its terms will distance Northern Ireland from the rest of the United Kingdom.

The DUP said in a statement Wednesday that they would continue to oppose what they called an "unacceptable" deal.

May's proposed agreement sets out only the terms of divorce with the E.U. If she does step down, it would be up to her successor — a person elected by some 120,000 Conservative Party members — to negotiate the future relationship with Europe on behalf of the whole U.K.

In the British political system, the ruling party can change leaders without the need for a general election.

May's attempts to force through her deal has led to repeated defeat and political humiliation. The Brexit process is regarded by many as the biggest peacetime political crisis ever faced by Britain, with deep, bitter divisions on the issue running through both major parties.

Some of the prime minister's own lawmakers attempted, unsuccessfully, to topple May in December. The next month, opposition lawmakers tried and failed to oust her government.

May suggested that her resignation would be contingent on her deal passing. There has been speculation she could bring it back for a third attempt this week.

If it fails again, Britain may need to ask for a longer extension to Brexit. The original divorce date has already been pushed back from March 29 until at least April 12.

If there is no deal and no extension, then Britain will crash out of the E.U. without a deal. This prospect has some supporters, but most experts say it would severely harm the economy and trigger shortages of food, medicine and basic supplies.

On Monday, the European Commission said this scenario was becoming "increasingly likely."

Placards supporting both sides of the Brexit debate line the sidewalks outside the Houses of Parliament in London. Paul Ellis / AFP - Getty Images

May took over as prime minister after David Cameron resigned the morning after the referendum in 2016. After several weeks of wrangling between leadership hopefuls, May's competitors eventually bowed out, leaving her as the only candidate standing.

Britain's relationship with Europe has divided the Conservative Party for decades. After Margaret Thatcher, John Major and David Cameron, May is the fourth party leader whose time in power has been largely defined by unsuccessful attempts to resolve this tension.

For many lawmakers, the main sticking point in May's deal is an insurance policy designed to keep open the border between Northern Ireland, which is part of the U.K., and the Republic of Ireland, which will remain part of the E.U.

Known as the backstop, hard-line Brexit supporters fear that keeping this border open could trap their country in E.U. trading rules forever and have insisted on a time limit or an exit mechanism. The E.U., however, has refused to agree to this because of the real risk that a hard border could trigger a return to the kind of conflict that plagued Northern Ireland for 30 years.

There have been growing calls for a second referendum on the terms of May's Brexit deal. On Saturday, hundreds of thousands of protesters gathered in the capital demanding a new public vote, and almost 6 million have signed a parliamentary petition to cancel Brexit altogether.