PA Images was just 2,227 votes away from becoming Prime Minister in the general election, new analysis has revealed.

If the Labour leader had won seven marginal Conservative seats and formed a so-called “progressive alliance” with all other smaller parties – barring the Democratic Unionist Party (DUP) – it would have been enough to command a working majority.

The Labour Party has said it was prepared to form a coalition government, with Mr Corbyn announcing: "We are ready to serve."

However, if the Conservative Party had won just 287 more votes needed to secure five knife-edge Labour seats, they would have commanded a majority alone.

The calculation comes as the Tories were reeling from the loss of their majority, which it had looked as though they would substantially increase when Theresa May called the election in April.

The DUP, which increased its number of seats to 10, said it was working on a deal with the Tories whereby it would support them on a vote-by-vote basis.

With seven more Tory constituencies falling to him, a coalition of Labour, Liberal Democrats, Scottish National Party (SNP), Plaid Cymru, the Green Party and one independent MP in the House of Commons would have held 322 seats — enough for Mr Corbyn to enter number 10.

This figure is based on Labour winning Kensington, where counting has been suspended until Friday evening.

The Green Party, SNP, Plaid Cymru have all spoken in favour of alliances, although the Liberal Democrats – for whom a coalition with the Conservatives has already proved devastating – had ruled out joining with other parties.

Seven Tory constituencies, including those held by Home Secretary Amber Rudd and former minister Stephen Crabb, were won with small majorities in the tens or hundreds, including Southampton Itchen, Preseli Pembrokeshire, Hastings and Rye and Chipping Barnet.

Had the Conservatives seized five seats including Dudley North, Newcastle-under-Lyme, Crew and Nantwich and Canterbury from Labour – seats where Mr Corbyn's party won by a small margin – Theresa May would have gone into Brexit negotiations with a majority in the Commons.

However, even this would have been a huge disappointment to Mrs May, who claimed the reason she called the election was to secure a more substantial mandate for Brexit, as it would still have represented a much weaker position than the one from which she called the election.