Britain’s two main political parties are haggling over the nation’s withdrawal from the European Union, but even with the departure on hold for the next few months, the badly divided government remains in crisis, unable to agree on an approach to the country’s biggest peacetime decision in decades.

Prime Minister Theresa May paid for the struggles with her job, announcing on May 24 that she would resign after failing to come up with a plan that satisfied her party, her coalition partners and officials in Brussels.

Three times this year, Parliament soundly rejected the plan that Mrs. May negotiated with the European Union for the departure, commonly known as Brexit, and the bloc twice agreed to postpone the exit date. Unable to win over enough members of her own Conservative Party, even when she offered to quit in exchange for their support on the third try, Mrs. May was forced to begin negotiating with the leader of the opposition Labour Party, Jeremy Corbyn. Those talks eventually collapsed.

The new deadline is effectively Oct. 31, and all options remain on the table, including leaving without a deal — a situation that many fear will be economically damaging. At the other extreme, abandoning Brexit altogether is still a possibility, as are assorted approaches in between, varying in how closely Britain would remain tied to European trade rules.

Whoever replaces Mrs. May will inherit an intractable situation that has defied all attempts to solve it. Parliament has already weighed several options — including whether to have a second referendum on Brexit — and voted all of them down.

Already some companies have jumped ship and moved their operations to other countries, worrying about the consequences of a no-deal Brexit, of a well-managed Brexit, and even of an indefinite delay. Fears of medicine and food shortages in a no-deal departure persist.

What ultimately emerges could determine the shape of Britain and its place in the world for decades. Following is a basic guide to Brexit, what it is, how it developed into the mess it is today and how it could ultimately be resolved.

What is Brexit?

A portmanteau of the words “Britain” and “exit,” Brexit is shorthand for Britain’s split from the European Union, changing its relationship to the bloc on trade, security and migration.

Britain has been debating the pros and cons of membership in a European community of nations almost from the moment the idea was broached. It held its first referendum on membership in what was then called the European Economic Community in 1975, less than three years after it joined, when 67 percent of voters supported staying in the bloc.

In 2013, Prime Minister David Cameron promised a national referendum on European Union membership with the idea of settling the question once and for all. The options it offered were broad and vague — Remain or Leave — and Mr. Cameron was convinced that Remain would win handily.

Britons voted on June 23, 2016, as a refugee crisis made migration a subject of political rage across Europe and amid accusations that the Leave campaign had relied on lies and broken election laws. An ill-defined Brexit won 52 percent of the vote.

Not only did that not settle the debate, but it also saved for another day the tangled question of what should come next. After nearly three years of debate and negotiation, that remains unanswered.

How did the vote break down?

Most voters in England and Wales supported Brexit, particularly in rural areas and smaller cities. That overcame majority support to remain in the European Union in London, Scotland and Northern Ireland. See a detailed map of the vote.

Young people overwhelmingly voted against leaving, while older voters supported it.

A detailed map of results of the Brexit vote

Why is it such a big deal?

Europe is Britain’s most important export market and its biggest source of foreign investment, and membership in the bloc has helped London cement its position as a global financial center. An announcement, or at least a threat, from a major business to leave Britain because of Brexit is a regular occurrence. The list of companies that are thinking about relocating includes Airbus, which employs 14,000 people and supports more than 100,000 other jobs.

The government has projected that in 15 years, the country’s economy will be anywhere from 4 percent to 9 percent smaller under Brexit than it would inside the bloc, depending on how it leaves.

Mrs. May had promised that Brexit would end free movement, the right of people from elsewhere in Europe to live and work in Britain and vice versa. That was a triumph for some working-class people who see immigration as a threat to their jobs, but dispiriting for young Britons hoping to study or work abroad.

What’s holding it up?

Undoing 46 years of economic integration in one stroke was never going to be easy, and the Brexit process has been bedeviled by the same divisions that led to the referendum in the first place. Both Britain’s main parties, the governing Conservatives and the Labour opposition, are divided over what to do, leaving Parliament so factionalized that there may be no coherent plan that would get a majority.

Mrs. May spent 18 months negotiating a divorce deal with the European Union, shedding one cabinet minister after another in the process. Her plan would have kept customs and trade arrangements at least temporarily, but ultimately envisioned cutting most of those ties. It did not detail what would replace them in Britain’s future relationship with the European Union.

When she presented her plan to Parliament in January, it was rejected by a historic margin of 230 votes. When she tried again in March, she fared less badly, but the pact was still soundly defeated, 391 to 242.

Some ardent Brexiteers, who would accept a no-deal withdrawal, came around to supporting Mrs. May’s deal — not because they liked it, but because they believed it might be their only chance to avoid a soft Brexit or remaining in the bloc. But a third attempt to pass her bill, also in March, failed 344 to 286.

That prompted Mrs. May to do something she had hoped to avoid: negotiate with Labour, which advocates a soft Brexit. Those talks failed to accomplish anything that would allow her to proceed, and she was eventually forced to abandon plans for a fourth vote. The revised plan was scorned by both Conservative and Labour lawmakers, and the decision not to publish the plan, let alone hold a vote, was a clear sign that Mrs. May’s days were numbered.

What happens next?

Britain has also had the odd experience of voting for officers of a club that it intends to leave.

Elections to the European Parliament take place May 23-26, and every European Union member nation is required to participate, even those that no longer want to be members.

That is an especially awkward position for Conservatives, whose voters and elected representatives are more likely to be pro-Brexit. Some party officials have warned that euroskeptic Tory voters, anticipating Brexit and frustrated with their representatives, will have little incentive to cast a ballot, setting the party up for a defeat. That has created a situation in which anti-Brexit parties are positioned to defeat traditional parties.

We keep hearing about the
Irish border. What’s that about?

The single greatest hangup is the question of Britain’s only land border with the European Union — the invisible line between Ireland, another member state of the bloc, and Northern Ireland, which is part of the United Kingdom.

Mrs. May and her Irish counterpart, Leo Varadkar, want to prevent checkpoints from going up at the border; such barriers are generally seen as incompatible with the Good Friday Agreement of 1998, which brought respite from decades of violence in Northern Ireland.

But the method she agreed for guaranteeing that — called “the backstop” — has alienated much of Parliament.

The backstop would keep the United Kingdom in a trading relationship with Europe until a final deal to avoid a hard border could be agreed on, something that hard-line Brexiteers fear would never happen.

And it would bind Northern Ireland to even more European rules, to the dismay of those who reject any regulatory differences between Northern Ireland and the rest of the United Kingdom. Most notably, that includes the Democratic Unionist Party of Northern Ireland, whose 10 lawmakers give Mrs. May her parliamentary majority.

How did we end up with a Halloween deadline?

Just about the only clear decision Parliament has made on Brexit since the 2016 referendum was to give formal notice in 2017 to quit, under Article 50 of the European Union’s Lisbon Treaty, a legal process setting it on a two-year path to departure. That set March 29, 2019, as the formal divorce date.

When it became clear that Parliament would not accept Mrs. May’s deal by then, the European Union pushed the precipice back to April 12, to allow her to try again. The timing was dictated by the coming European Parliament elections, the thinking being that if Britain were to take part in that vote, it would need to begin preparing at least six weeks in advance.

Once again, the “cliff edge” of a no-deal Brexit loomed, but the new deadline did not yield any more agreement in London, forcing Mrs. May to plead, again, for more time. European leaders insisted on a longer delay this time, and set Oct. 31 as the date.

That could allow time for a second referendum or a general election, and speculation about both has been rampant, though the prime minister has rejected the ideas.

That, in theory, provided time for Mrs. May and Mr. Corbyn to agree on a new approach to propose to the European Union, but the parties remain far apart and Labour has little incentive to help the Conservatives solve the problem. In addition, the European Union has insisted that it will not reopen negotiations on the withdrawal agreement it negotiated with Mrs. May.

In announcing her decision to step aside, Mrs. May acknowledged that lawmakers had yet to find a way to pass that deal, or to agree on what they want instead.

The fantasy that Brexit would be easy has crumbled, and lawmakers who made lofty promises to their constituents are having to face hard reality.

Somehow, having the nightmare come to a head — again — on Halloween seems fitting.

What are the alternatives?

Mrs. May’s successor, whoever it is, will no doubt be aware of the obstacles. A hard-line Brexiteer might be content with a no-deal withdrawal, but a less-strident replacement could tack to the center by committing to a customs union with Europe — a close trading relationship that would prevent the imposition of tariffs and quotas. That would solve the Irish border dilemma and possibly win votes from Labour lawmakers.

It would be a softer Brexit than the one Mrs. May had negotiated. Britain would remain bound by European tariff rules, and by some of the bloc’s product standards.

But that would enrage right-wing lawmakers in the Conservatives and risk splitting the party, which she wants to avoid at all costs. Mrs. May spent months trying and failing to win over hard-liners who want a harder Brexit, with fewer ties to the bloc.

Of the options considered by Parliament this year, the one it came closest to endorsing was a soft Brexit approach, remaining in the customs union. That proposal lost, 272 to 264, in a nonbinding vote, but more than 100 lawmakers abstained, so it is anyone’s guess how the vote would have gone if every lawmaker had taken part.

Mr. Corbyn has worked hard not to commit Labour to a distinct course on Brexit. But under pressure from many of his members, he has expressed a willingness to back a second referendum under certain circumstances.

But a referendum could take many forms, and even among its backers, there is no agreement on that, either.

One of the options Parliament considered was a popular vote to confirm or reject Mrs. May’s deal. That lost, 295 to 268, but once again, more than enough lawmakers abstained to sway the outcome.

Many Brexit opponents want a different referendum, a rerun of the 2016 contest, asking voters if they want any Brexit at all. Polls indicate that public opinion has shifted in favor of remaining in the European Union, but so far, Parliament has not considered such a measure.

Still other pro-Europe voters want Parliament to kill Brexit on its own, or at least delay it for years, by revoking Article 50.

Exiting without a deal in place also remains a real possibility, one that the hard-line pro-Brexit forces in the Conservative Party insist would be preferable to a long delay.

Visit our more detailed guide to what could happen next.

A more in-depth guide to what could happen next