It's on. Britain is going to the polls again. And there's a chance - just a chance - that this Brexit mess will be sorted one way or the other.

It was clear which way the wind was blowing once the government had come to terms with the SNP and Lib Dem bill from earlier in the week. It didn't really have any other options. It lost its Fixed-Terms Parliament Act attempt yesterday. That required a two-thirds majority, but allowed it to set the date - something which made opposition parties nervous. So Johnson dropped it and produced a short bill this morning with a December 12th date on it. It would have a slim majority with SNP and Lib Dem support. And once that happened, Labour had to come on board.

For a couple of moments, it still looked like it could run into trouble. The government put forward a programme motion - a plan for passing the bill quickly through the Commons - which allowed it to place amendments but not opposition parties. Standard-issue dirty tricks from an administration defined by them. Labour sounded like it might refuse to support that.

But then Labour MP Stella Creasy put down an amendment unlocking further amendments from opposition parties. It got through and the rest of the party then fell in behind it.

Even then there were potential problems. An amendment was put down to give votes to those aged 16-17 and another for EU citizens. If they had passed, the government would have pulled the bill. But the deputy Speaker did not select them, as they were considered outside the scope of the legislation - insufficiently connected to its purpose.

The final battle came down to a single amendment, which would have moved the date to December 9th. This got close. Just hours before it was voted on, ten Tory MPs who had lost the whip over the no-deal votes last month had it returned to them. It was a crucial move. In the end, the amendment was defeated with the votes of exactly ten MPs.

That was it. It was done. The election would be held on December 12th.

The next few weeks will be a brutal, no-holds-barred battle for the future of this country. It'll be ugly and it'll be harsh. But it is also necessary.

The reality is that Johnson's Brexit deal was on the verge of passing the House of Commons. It almost passed ten days ago, when MPs instead broke cover for Oliver Letwin's amendment. It nearly passed two days later, when it was narrowly saved by the rejection of the programme motion.

People seem to have forgotten how close these votes were. There were no safety nets left. If they'd gone through, Brexit would be happening right now. Remainers were at the point of absolute defeat. They were wobbling on the cliff edge. And then the government made a high-risk strategic decision. It gave up on the deal and decided to go for an election.

It is a quite mad thing to have done. They could have got that deal through if they'd had a bit of patience and then they could have held an election afterwards. But they made a different choice. And Remainers should breathe a sigh of relief that they did. They have nothing to lose from it and much to gain.

No matter what people say, the Commons was not on the verge of supporting a second referendum. It wasn't going to do it on Johnson's deal. If it did it at all, which was questionable, it would have done so if the deal was defeated. But the deal did not look like it would be defeated. It looked like it was going to pass.

And even if a vote had eventually gone through supporting another referendum, it wouldn't have been enough. It would have required a government to pass legislation to hold it. This government wouldn't have done it. So there would have had to be a vote of no confidence, then the opposition parties would have had to select a prime minister - something they had so far utterly failed to do. Then they'd have had to get the full legislation enacting the referendum through via an unelected majority government. And then somehow win it.

It simply wasn't going to happen. It's silly to pretend it would.

But then Johnson decided to go for an election.

He can be made to suffer extensively for that decision. Yes, he has a lead in the polls. Yes, Jeremy Corbyn is unpopular. Yes, Remain is more divided that Leave. But for all that, it is a fairly even contest.

There is a geographical split in the Remain vote which is to its advantage. Opposition parties have multiple coalition opportunities open to them while Johnson has none. It can be won. A minority Labour government relying on Lib Dem and SNP support is a perfectly likely outcome. And that outcome leads to a second referendum.

There are no guarantees. This will be the most uphill, fraught, emotional, gruelling political battle many Remainers will have ever faced. But now they have a chance. And they have been saved from the relentless, and increasingly inevitable, crunching momentum towards the deal passing.

It's a good day. Full of risk, but also full of potential. And more importantly: there were no other avenues open. This was the only one.

The fight is now on. For many of the people involved, it'll be the most important one of their lives.

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.