The shadow chancellor said forcing an election would be “very difficult”.

And if it was not possible, he told the BBC’s Laura Kuenssberg, the party would push for another referendum.

Mr McDonnell told the BBC’s political editor: “We want a deal that will protect jobs and the economy.

“If we can’t achieve that – the government can’t achieve that – we should have a general election, but that’s very difficult to do because of the nature of the legislation that David Cameron brought forward.

“If that’s not possible, we’ll be calling upon the government then to join us in a public vote. It’s difficult to judge each stage, but that’s the sequence I think that we’ll inevitably go through over this period.”

Asked by Laura Kuenssberg if a vote of no confidence did not bring down the government and lead to a general election, a second referendum was “inevitable”, Mr McDonnell replied: “That’s right.

“Our policy is if we can’t get a general election, then the other option which we’ve kept on the table is a people’s vote.”

Asked about shadow home secretary Diane Abbott’s claim that the Leave side could win another referendum, he said: “It might do. It’s very difficult to call at the moment.”

He said most of the Labour MPs campaigning for another referendum were the “strongest Remainers”.

“So, the caution for them and for all of us, whichever argument you put, is the people will decide. As we saw in the last referendum, it’s very difficult to predict which way the people will decide on this.

“I’ve seen a lot of polls that have said there has been a shift from Leave to Remain. I’ve also seen other polls saying actually we’re just about the same as we were then.”

He said he had voted Remain in the 2016 EU referendum and he believed it was still the “best option” but he also respected “the wishes of the people”.

If there were to be another referendum, he said, there would be a “debate” in the Labour Party about its position but it could not support Theresa May’s “current” deal, if that were on the ballot paper.

Prime Minister Theresa May, who is Conservative Party leader, said that Mr McDonnell’s comments about another referendum showed that “the true Labour position” was that they want to “frustrate Brexit”.

Speaking in Scotland, the prime minister said another referendum would be a “betrayal of the vote of the British people” adding that the Government had negotiated a deal that “delivers Brexit” while “protecting jobs, protecting livelihoods, protecting security and protecting our United Kingdom”.

A fresh referendum could be held only if the government legislates for one and a majority in the Commons supports it.

Theresa May has faced repeated calls to hold another referendum from Labour, Lib Dem, SNP, Green and a small number of Conservative MPs, who are members of the People’s Vote campaign, but has always rejected them.

Under the Fixed-Term Parliament Act, introduced in 2011 by David Cameron’s coalition government, a general election can be called if two-thirds of MPs vote for one.

Alternatively, if a majority of MPs back a no-confidence vote in the prime minister, a 14-day period is allowed for a new government to be formed with the approval of MPs. If no such vote is passed, a new election must be held.