Britain ushered in a new era Wednesday when Boris Johnson replaced Theresa May as prime minister with a vow to lead the country out of the European Union by Oct. 31 — “no ifs or buts,” and that “the buck stops here.”

The brash 55-year-old former mayor of London and foreign secretary — who was elected leader of the governing Conservative party a day earlier — was confirmed prime minister in a meeting with Queen Elizabeth II.

Johnson then strode to his new digs at 10 Downing St., where he slammed “the doubters, the doomsters, the gloomsters” who don’t believe he can break the Brexit impasse that sent May packing.

“The people who bet against Britain are going to lose their shirts,” he said as he promised to usher the UK out of the EU “after three years of unfounded self-doubt.”

Hailed by President Trump as Britain’s version of himself, Johnson sent the strongest message yet to the EU that he would take a markedly tougher approach to negotiating the Brexit deal — warning that if the 28-nation bloc balked, there would be a no-deal divorce.

Chief EU Brexit negotiator Michel Barnier said “we are ready to listen and to work with” Johnson, but did not budge on the bloc’s refusal to alter the deal.

“A no-deal Brexit will never be, never, the choice of the EU. But we are prepared,” he said in Brussels.

Famed for his bravado and ruffled blond hair, Johnson easily defeated Conservative rival Jeremy Hunt, the foreign secretary, who was offered the job of defense minister but turned it down, according to Sky News TV.

Johnson’s office said his government would be a “cabinet for modern Britain” with more women and a record number of ministers from ethnic minorities — a sign that he hopes to move beyond the largely white, male and Conservative members who chose him as their leader.

He wasted no time in getting rid of three top cabinet members — Defense Secretary Penny Mordaunt, International Trade Secretary Liam Fox and Business Secretary Greg Clark, all of whom had backed Hunt.

Clark is a vocal opponent of a no-deal Brexit. Mordaunt and Fox are leading Brexiteers. Others who have apparently been shown the door included Education Secretary Damian Hinds, Northern Ireland Secretary Karen Bradley, Communities Secretary James Brokenshire and Transport Secretary Chris Grayling, according to the BBC.

Conservative MP Nigel Evans described the purge as a “summer’s day massacre.”

In his 13-minute speech outside Downing Street, Johnson listed a litany of domestic goals, including a promise to sort out care for the elderly “once and for all.”

“We will fix it once and for all with a clear plan we have prepared to give every older person the dignity and security they deserve,” he said.

He also pledged to improve infrastructure, recruit 20,000 new police officers, “level up” school spending and boost the UK’s biotech and space science sectors.

Johnson assumed power in a day of meticulously choreographed political drama that began with May attending the weekly Prime Minister’s Questions period in the House of Commons for the final time.

Conservative colleagues praised May for her sense of duty, while opposition leaders offered best wishes and took shots at her replacement.

May shook her head when Labour Party leader Jeremy Corbyn, who paid tribute to her “respect for public service,” asked if she would help him stop “the reckless plans of her successor.”

She then offered Johnson slightly muted praise, saying she was pleased to hand control over to a Conservative committed to “delivering on the vote of the British people in 2016 and to delivering a bright future for this country.”

As she left the Commons chamber, May was given a standing ovation by Conservative lawmakers and later stood outside the prime minister’s residence, where she said it had been “the greatest honor” to serve as prime minister.

May and her husband, Philip, then traveled about a mile to Buckingham Palace to present her resignation to the 93-year-old monarch and ask her to advise Johnson to form a new government.

Moments after the former leader left the palace, Johnson’s car dodged Greenpeace protesters who tried to block its path to the gates of the royal residence, where he was named the 14th prime minister of the queen’s 67-year reign.

With Post wires