LONDON — British Prime Minister Theresa May struck a deal in principle with Northern Ireland’s Democratic Unionist Party on Saturday to prop up the Conservative government, stripped of its majority in a disastrous election.

The result has demolished May’s political authority, and she has also lost her two top aides, sacrificed in a bid to save their leader from being toppled by a furious Conservative Party.

But the ballot-box humiliation has seriously – and possibly mortally – wounded May’s leadership just as Britain is about to begin complex exit talks with the European Union.

Downing Street chiefs of staff Nick Timothy and Fiona Hill, who resigned Saturday, formed part of May’s small inner circle and were blamed by many Conservatives for the party’s lackluster campaign and unpopular election platform, which alienated older voters with its plan to take away a winter fuel allowance and make them pay more for long-term care.

In a resignation statement on the Conservative Home website, Timothy conceded that the campaign had failed to communicate “Theresa’s positive plan for the future,” and missed signs of surging support for the opposition Labour Party.

Some senior Tories had made the removal of Hill and Timothy a condition for continuing to support May, who has vowed to remain prime minister. May’s party won 318 seats, 12 fewer than it had before May called a snap election, and eight short of the 326 needed for an outright majority. The main opposition Labour Party surpassed expectations by winning 262.

May announced later that Gavin Barwell – a former housing minister who lost his seat in Thursday’s election – would be her new chief of staff. May said Barwell would help her “reflect on the election and why it did not deliver the result I hoped for.”

Conservative legislator Nigel Evans said the departure of the two aides was “a start,” but there needed to be changes to the way the government functioned in the wake of the campaign.

He said the Conservative election manifesto – which Hill and Timothy were key in drafting – was “a full assault on the core Tory voters, who are senior citizens.”

“It was a disaster,” he said. “Our manifesto was full of fear and the Labour Party’s manifesto was full of promises.”

Martin Selmayr, senior aide to European Commission President Jean-Claude Juncker, responded to the resignations by tweeting the word “bauernopfer” – German for the sacrifice of a pawn in chess.

May’s office said Saturday that the Democratic Unionist Party, which has 10 seats in Parliament, had agreed to a “confidence and supply” arrangement with the government.

That means the DUP will back the government on key votes, but it’s not a coalition government or a broader pact.

Downing Street said the Cabinet will discuss the agreement Monday.