David Cameron has hit out at Boris Johnson and his Brexit strategy, saying the prime minister was wrong to suspend parliament and warning that a no-deal Brexit would be a “bad outcome”.

It rounded off a dismal day for the prime minister after a trip to Yorkshire descended into chaos when he was confronted by an angry voter over Brexit in Doncaster and heckled over the suspension of parliament during a speech in Rotherham.

The prime minister was setting out plans to hand more powers to the north of England, but was derailed by an audience member, who shouted: “Why are you not in parliament sorting out the mess you’ve created?”

Mr Johnson said he was “cautiously optimistic” of getting a Brexit deal as he prepared for talks on Monday with Jean-Claude Juncker, the European Commission president, and negotiator Michel Barnier.

He claimed there was the “rough shape” of a deal in place.

But he made clear that if he was unable to get a new deal, he would not be deterred by “shenanigans” at Westminster from taking Britain out of the EU by 31 October.

His last-but-one predecessor Mr Cameron claimed Mr Johnson had behaved “appallingly” during the Vote Leave campaign.