A top cabinet ally of Boris Johnson has quit over the prime minister’s purge of anti-Brexit conservatives — and said six other ministers could bolt as well in what is emerging as a major challenge to the British leader’s government.

Amber Rudd, Johnson’s work and pensions secretary and till now a staunch supporter, resigned from her post, the Sunday Times of London reported.

Rudd left the Conservative Party in “disgust” over Johnson’s jettisoning of fellow Tories last week, but the defiant Johnson shows no sign of backing down.

This despite opposition leaders warning he could end up in jail if he follows through on his plan to take the UK out of the European Union on Oct. 31 whether or not an official divorce agreement has been reached.

A law requiring the British prime minister to ask the EU for an extension of the Halloween deadline passed both houses of Parliament on Friday — but Johnson vowed he’d “rather be dead in a ditch” than ask for a delay.

Opposition members are readying a court case to force Johnson to obey, the BBC reported.

“A refusal in the face of that would amount to contempt of court, which could find that person in prison,” former Director of Public Prosecutions Lord Ken MacDonald told Sky News.

But Johnson is convinced he holds the upper hand.

A YouGov poll out Sunday gives his party 35% support — 14 points ahead of the rival Labour Party, the Sunday Times reported — enough to win him a parliamentary majority if a general election is called.

His advisers are spinning multiple strategies to sabotage Brexit-blocking efforts, including a scheme that would have him resign his post to force a snap election.

Duncan Smith, former Conservative Party head, said that could make the prime minister a Brexit “martyr.”

“This is about Parliament versus the people,” Smith told the Telegraph newspaper. “Boris Johnson is on the side of the people, who voted to leave the EU.”

Meanwhile, Johnson’s opponents — including leaders of the Labour Party and anti-Brexit Tories — have been privately negotiating with European leaders, the Times of London reported Saturday.

They have been promised that the European Council will grant a request for a three-month Brexit extension if Johnson requests one.