Media playback is unsupported on your device Media caption MPs voted by 391 to 242 against Theresa May's Brexit plan

Theresa May's planned Brexit deal has suffered a major defeat in the UK parliament, leaving the Brexit process in disarray.

Mrs May began the day with renewed hope after securing last-minute changes to her withdrawal deal with the EU.

But MPs roundly defeated her proposals, 391 votes to 242, weeks after her first attempt to pass the deal met the same fate.

Had the vote gone her way, the UK would be preparing to leave the EU on 29 March.

That exit date still looms large, but things could go a few different ways before then.

So what happens next?

The next step is... another vote (this one on Wednesday). MPs will vote on a motion on whether to allow the UK to exit the EU on 29 March without a deal - a so-called "disorderly" or "no-deal" Brexit.

Leaving the EU without a deal - and therefore without the 21-month transition period provided for by the deal - carries significant risks for trade, immigration, health, and more, and parliament will almost certainly reject that possibility.

Rejection of a no-deal Brexit would then set up... yes, you guessed it: another vote.

This one would decide whether Mrs May will go back to the EU to request an extension to Article 50 - the formal name for the notification from the UK that it is leaving the union.

That would throw the Brexit ball into the EU's court - potentially allowing the union to decide the terms of any extension period.

Speaking after her defeat on Tuesday, Mrs May said: "Voting against leaving without a deal and asking for an extension does not solve the problems we face. The European Union will want to know what use we mean to make of such a extension, and this house will have to answer that question."

What is the backstop?

Much of the dissent - and last-minute wrangling - over Mrs May's deal revolved around the so-called backstop. Both sides have committed to avoiding the return of a hard border - physical checks or infrastructure - between Northern Ireland and the Republic of Ireland.

At present, goods and services are traded between the two jurisdictions on the island of Ireland with few restrictions. The UK and the Republic of Ireland are both part of the EU single market and customs union, so products don't need to be inspected for customs and standards.

Media playback is unsupported on your device Media caption Confused by Brexit jargon? Reality Check unpacks the basics.

If the UK leaves, that changes. The backstop is a safety net, an arrangement that will apply to the Irish border after Brexit if a wider deal or technological solution can't be found that keeps the border as frictionless as it is today.

But Conservative Brexiteers are concerned that the backstop could keep the UK indefinitely locked into an arrangement with the EU, if no alternative is found.

Mrs May hoped her last minute amendments to the deal would resolve the backstop issue, but the attorney general, Geoffrey Cox, made it clear on Tuesday that the risk of being locked into the backstop remained.

What does defeat mean for Theresa May?

The prime minister is embattled. Her short premiership has been dogged by the Brexit negotiations, which has now served her up two massive parliamentary defeats.

Mrs May was suffering from a sore throat on Tuesday as she stood up in the House of Commons to defend her deal, after late-night negotiations in Brussels, knowing all the while that she stood a strong chance of another defeat.

Her first attempt to pass a Brexit deal through the Commons was roundly rejected in January, brought down by a large rebellion against her from within her own party.

Now a second significant defeat in the Commons risks weakening Mrs May's party leadership even further, and amplifying calls for her resignation.

Among the possible outcomes should parliament be unable to agree on the terms of a deal, the prime minister might also face a general election - the second of her premiership.

Speaking in the House of Commons after the vote on Tuesday, the opposition Labour leader Jeremy Corbyn said it might be time to... you guessed it: have another vote.