In the end, it was all for nothing. What was billed as the war to decide Brexit turned out to be just another battle. But what happened in parliament today will set the stage for a brutal last-ditch fight in the weeks to come, as opponents of Boris Johnson's deal struggle in the trenches to try and stop it.
Johnson's deal triggered something. It is, in truth, a bad deal. It's certainly worse than that brought back by Theresa May. But MPs are so fed up with the Brexit issue, so desperate to get a result, that they looked ready to support it. The DUP rejected it, but many of the purged Tories, who were thrown out over opposing Johnson a few weeks ago, seemed reluctantly willing to back it, as were many pro-deal Labour MPs. It looked like it could just about slip through.
If it had done so, the question of whether Britain will leave the EU would now be over. It would be settled. But then Oliver Letwin, not for the first time in this saga, threw a spanner in the works.
He introduced a very simple but devastating amendment. It stated that the House would not have given consent to the deal until the government had passed the full legislation implementing it - not just the short one-paragraph motion asking if MPs backed it.
Politics has an ironic sense of morality sometimes. If the Brexiters in the hardline ERG faction had behaved with more honour in the last few years, the amendment would not be necessary. But Letwin didn't trust them. He was worried that they had an opportunity to subvert the Brexit process to secure no-deal.
If the deal had passed today, it would have neutralised the Benn Act. This stated that if a deal had not been approved by 11pm tonight, the prime minister had to request an extension of Article 50 from the EU. Once that happened, there would be no insurance policy against no-deal. The ERG could then sabotage the deal by voting against the legislation implementing it.
That was the danger scenario the amendment sought to address. It locked in a deal. Only if the full law was passed would it be considered to have consent.
The votes came in tight. As MPs debated in the Commons, and a steady stream of enormous roars shook parliament from the hundreds of thousands of People's Vote protestors outside, the ten DUP MPs in the Chamber went off for a meeting with ministers. For a moment it seemed that they might abstain.
If they had done, it would have failed. It was a heart-stopping moment. The amendment passed by just 322 to 306. That meant that it rested on eight MPs. The DUP's lack of support had cost Johnson everything. The motion was then passed with the amendment. It meant there would be no meaningful vote on the deal. MPs were forcing the government to bring forward the legislation.
That opens up a new stage of battle over Brexit. But it is only a temporary reprieve. The reality remains stark. Johnson has the upper hand.
Look at the numbers. The amendment passed by eight votes. But those votes will not translate directly into opposition to Johnson's deal. Plenty of the purged Tories have said they are prepared to vote for the deal.
Nick Boles, Ken Clarke, David Gauke, Oliver Letwin and Antoinette Sandbach all voted for the amendment and have said they would vote for the deal. The government probably expects to tempt over Phillip Hammond and Amber Rudd. There were also Labour MPs sympathetic to a deal, like Gareth Snell, who backed the amendment.
Basically the numbers are eye-wateringly tight. As things stand, the prime minister probably has a majority for his deal - of a handful of votes, maybe as few as one or two. Everything is poised on a knife edge.
Publishing the legislation could change everything though. Having all the details out there, in brutal black and white, might change minds. It's possible that it could outrage the ERG sufficiently to turn it against the deal, although given how rock-solid they were today that seems unlikely. It might push wobbling Labour MPs into opposition.
Amendments on it could force the debate in one direction or another. It might give MPs a chance to secure a second referendum. Or the DUP could use amendments to protect Northern Irish trade with Britain.
On the other hand, the govt could use amendments to provide more paper-thin assurances to Labour MPs and pull them over into backing it.
Either way, it puts the debate in a new setting, on different terms, with new battlefields, and on an extended timetable. It means critics of Johnson's deal are now in a guerilla warfare campaign, their backs against the wall, using whatever tactics they can find to try and stop this thing.
Today's vote was a pause and reformulation of the assault - it did not stop it.
And then, as the session wound down, the sun came out and crowds started celebrating in parliament square, the government tried a new trick.
When he responded to the vote, Johnson seemed to confirm that he would bring forward the legislation next week. But then suddenly something changed. Jacob Rees-Mogg, the leader of the House, got up to speak. And he said something extraordinary.
On Monday, he said, the Commons would vote on a motion under Section 13.1b of the European Union Withdrawal Act. That is the meaningful vote mechanism.
It was an incredible thing to say. It meant the government intended to ignore the result today - simply pretend it never happened - and then try to force the House to again back the deal on a basic motion, rather than the legislation.
Mogg didn't even announce this using a normal business of the House statement. That would've meant that he would have to take questions from MPs. Instead, he did it using a point of order. He could just say it and sit there, silent, failing to answer any of the issues which rose from it. Then he simply got up and walked away from the Chamber, followed by shouts of "outrageous".
The government seems desperate not to publish that legislation. But it's not clear that they can get away with it. When May tried to pass her deal through the House repeatedly, she was stopped by Speaker John Bercow. Governments that lose votes aren't supposed to just keep on trying until they get the answer they want.
"What the government is attempting to do," Letwin said, "is nothing more and nothing less than to repeat what would have been the effect of today."
Bercow seemed to feel the same way. He fired a warning shot at the government. "The apparent purpose of the said motion which ministers are attempting to table is to invalidate or obviate the effect of the decision which the House reached today," he said. "And that does seem most curious or irregular." This is parliament-speak for a fight. "The government is not the arbiter of what is orderly. That cannot be so. And it is not so. And it will not be so." Chances are Bercow will kill this effort on Monday.
Meanwhile, Johnson was planning dirty tricks on his other front. "I will not negotiate a delay with the EU," he told the Commons after the vote. "And neither does the law compel me to do so."
It's true. The law requires him to request an extension of article 50 by 11pm tonight, until January 31st 2020. But he does not need to go and try to convince the EU to accept that request. And he will almost certainly now push them to stay silent.
Let's be clear. No matter what anyone says, the EU will not reject it. They won't throw out a member against their will and they will not sacrifice the Republic of Ireland to the chaos of no-deal. But they don't have to reply to the request until the end of the month, possibly even the day before October 31st. And their interests are now aligned with Johnson. They want the deal and so does he. So to increase the pressure on parliament they may well decide to hold off on that decision.
This is stark, harsh, brutal political warfare, with impossible odds. Remainers are up against it. The government is using numerous dirty tricks to force them to capitulate. The EU are being unhelpful. MPs are volatile and jittery. The numbers in the Commons, for the first time, seem to be narrowly for a deal.
But this is very far from over. The legislation will be a horror show, which could change the debate. The legal background is firm - the Benn Act is triggered and an extension will be granted.
And there's something else, something more important. Today, in central London, hundreds and hundreds of thousands of people marched for a People's Vote. They snaked through the capital, from Hyde Park to Westminster, in extraordinary numbers. They have been libelled and laughed at and belittled - by MPs, political leaders, journalists and others - for over three years. But they have not given up. They have fought, relentlessly, unceasingly, against Brexit.
They have the strength to win this, to pressure MPs, to make the case, to win the argument. And now they have more time to do so and more weapons to use. This thing is about to enter its most dangerous stage. But it is not done. It can still be turned.
The government lost today. And it can lose next week too.
Ian Dunt is editor of Politics.co.uk. His new book, How To Be A Liberal, is out in spring 2020.
The opinions in Politics.co.uk's Comment and Analysis section are those of the author and are no reflection of the views of the website or its owners.