Almost all Labour MPs expected the party to lose seats at the general election. Some feared the opposition would endure its worst result since 1935, winning as few as 150. Instead, Jeremy Corbyn has achieved what Ed Miliband did not and gained seats (from 232 to 261).

When Corbyn allies briefed before the result that he would remain leader even if the party lost, the Labour leader's opponents set him the test of adding MPs (as Neil Kinnock did in 1987) — it is one he has passed. Corbyn's aides are also hailing a 10-point surge in their vote share (from 30 per cent to 40 per cent) - the largest increase since 1945. Though it is only seats that count in Parliament, Labour has turned previously safe Conservative constituencies into marginals.

Crucially, this result was because of the campaign, not in spite of it. The party's manifesto, stuffed with popular policies, transformed Labour's standing and Corbyn impressed in TV appearances (with his personal rating improving from -42 to -2). Labour's disciplined campaign showed the leader in his best light — addressing packed rallies — and avoided the divisions that plagued Ed Miliband in 2015. Allies of the former leader are lamenting that he should have fought the 2015 election on a more "radical" programme.

The result of all this, as a shadow cabinet minister told me last night, is that "Jeremy's safe for as long as he wants". Though MPs were always planning to avoid an early challenge to Corbyn, the prospect of one at any point has evaporated. As Chuka Umunna, one of those who was set to stand, observed: "The only talk of replacing a leader is around Theresa May. Jeremy Corbyn will remain leader of Labour, quite rightly so".

Corbyn allies say that he now has a "mandate" to introduce "fundamental" changes to the party and policy. A reduction in the leadership nomination threshold to 5 per cent of MPs/MEPs — ensuring a permanent left presence in future contests — is now more feasible. Whoever eventually follows Corbyn will need to embrace substantial parts of his programme to command activist support. The leader's allies long feared that the party's leftwards shift would prove temporary; last night has rendered it permanent.

Labour MPs, meanwhile, say that "the civil war is over" and that the unity forged during the campaign will endure. The prospect of yet another election will concentrate minds. If asked, former shadow cabinet ministers are prepared to return to the frontbench.

It should not be forgotten that Labour has lost a third successive general election, finishing 55 seats behind the Tories. Those MPs who warned that the British electorate would never make Corbyn prime minister were right. But as Theresa May has discovered, politics is all about expectations. Corbyn has dramatically exceeded them — and he will reap the rewards.