After nearly two and a half years of negotiations we have clarity of sorts from the government. A 585-page withdrawal agreement with a Northern Ireland backstop that appears to keep the UK in a regulatory and customs unions with the EU if no future trade deal is reached before the end of the transition period. And a 26-page, non-legally-binding political declaration of a future EU and UK relationship, which appears to leave almost every option on the table other than membership of the single market. There's just one problem. On the current arithmetic there appears to be no parliamentary majority for Theresa May's deal.

Which immediately creates a second problem regarding what comes next. All roads appear to end in impasse. A vote of no confidence in the government would almost certainly fail, as the last thing the Tories and the DUP want now is a general election. A vote of no confidence in the prime minister triggered by Brexiteers in the Tory European Research Group would almost certainly fail. May might go back to the EU and try to secure a few more last-minute concessions, but there's little chance of her managing to return with enough to win over Tory rebels.

In short, there's no clear majority for anything. No one wants May's Brexit and – thanks to Dominic Grieve's amendment, which defeated the government on Tuesday night – there's now little chance of parliament accepting a no deal Brexit. An extension to Article 50, delaying the UK's exit from the EU from 29 March next year is a possibility, but it is far from certain there is even a majority in the Commons for a second referendum. For the moment, at least, we are at deadlock.

The Labour leader wants it both ways. His credible alternative is to have no credible alternative

Nor does Jeremy Corbyn appear to have many answers. In all his Brexit speeches he seldom manages to offer any serious solutions. In one sentence he can criticise May for having negotiated too soft a Brexit and in the next accuse her of too hard a Brexit. The Labour leader wants it both ways. His credible alternative is to have no credible alternative, to wait until the Conservative government implodes under its own internal rivalries and contradictions and then step into the vacuum. As a political strategy for gaining power it may have some logic, but as an answer to Brexit it's a nonstarter.

And yet there is hope among the opposition benches. And that hope comes in the form of Keir Starmer, the shadow Brexit secretary. Starmer is something of an anomaly in the Corbyn shadow cabinet: the one figure who has genuine gravitas – he was head of the Crown Prosecution Service before becoming an MP – and can command support from both the left and the right of the party. He has already seen off two Brexit secretaries in David Davis and Dominic Raab and there's no reason to imagine he won't outlast the current one, Steve Barclay.

It has also been Starmer who has inflicted the biggest Brexit defeats on the government

Right from the time he was appointed, Starmer has played the long game, not just in taking on the government over its botched negotiations, but in slowly, slowly winning Corbyn round. At the time of the referendum – though notionally campaigning for Remain – to all intents and purposes the Labour leader gave the impression of being an ardent Brexiteer.

It was Corbyn who called for the UK to trigger Article 50 on the day after the referendum – imagine if that had happened – and for a long time he was also supportive of the UK leaving the customs union and the single market. But slowly, over time, Starmer has nudged him round. The shadow Brexit secretary's political antennae have been more fine attuned than those of his leader and Corbyn is now firmly committed to remaining in "a" customs union. Give it time and that "a" might become "the" customs union. And don't rule out a late conversion to the single market.

It has also been Starmer who has inflicted the biggest Brexit defeats on the government. After Davis boasted to the Brexit select committee that his department had undertaken economic impact assessments in "excruciating detail", it was Starmer – using an arcane piece of parliamentary procedure known as a humble address – who forced the government to reveal them. It then emerged that almost no work whatsoever had been done. Then, last month, Starmer used the same humble address to instruct the government to reveal the attorney general's legal advice on its Brexit negotiations. The government initially declined but then lost two votes on Tuesday.

For the first time in living memory, government ministers had been found in contempt of parliament

Thanks to Starmer, parliament reasserted its sovereignty over the executive. For the first time in living memory, government ministers had been found in contempt of parliament. This wasn't just a reversal for Theresa May: it was a complete humiliation. What was in the legal advice has only just been revealed. But either way, Starmer has played a blinder. If there is nothing damaging, then the government has been weakened by its own intransigence. And if the advice is as bad as some fear, then May's days in office are surely numbered. As if they weren't already.

But there's a twist in all this. Starmer's rising star – both with the Labour benches and in parliament in general – has not been altogether well received by Corbyn's team. There's a feeling that he may be lining himself up as a potential rival to take over as leader. Indeed, some members of Corbyn's inner circle have started briefing that Starmer has gone rogue, making up his own Brexit policy on the hoof. In interviews, the shadow Brexit secretary has shown himself to be increasingly well disposed towards a second referendum to break the parliamentary deadlock. Something Corbyn will only acknowledge as an absolute last resort, and even then through gritted teeth.

So it's just possible that the current Brexit impasse might not just spell danger for May. It could also spell trouble for Corbyn. The Labour leader has always relied heavily for his mandate on the support of the party membership rather than his own MPs. Now he finds himself caught in a bind. He is instinctively against a second referendum, for which the party membership is overwhelmingly in favour. Something has to give. And Starmer may yet turn out to be the right man at the right time to unite the party.

**Read more: **

Theresa May's Brexit deal is dead on arrival

Jacob Rees-Mogg's rebellion has fallen flat

Jo Johnson was the 18th minister to resign from May's government. He won't be the last