European Union leaders agreed on Tuesday to name France's Christine Lagarde as the new head of the European Central Bank and sealed a deal on filling the EU's other top four jobs after marathon talks that have exposed deep divisions in the bloc.
Three days of summit negotiations that at times looked close to collapse ended with a deal that now must be approved by the European Parliament but was immediately rejected by the socialist bloc.
"Done!" said Luxembourg's Prime Minister Xavier Bettel, who was first to break the news on Twitter that leaders had finally clinched a deal.
Leaders hope the decision to nominate two women, Lagarde and German Defence Minister Ursula von der Leyen, to the top of EU decision-making for the first time will send a positive message
and repair damage wrought by such a fractious summit, diplomats said.
The discord echoed a wider fracturing of the EU's political centre that was evident in May's European Parliament elections that delivered a more fragmented assembly in which no bloc won a majority and far-right and far-left groups performed strongly.
Under the deal, von der Leyen, a close ally of German Chancellor Angela Merkel, will replace Jean-Claude Juncker as president of the European Commission, the EU's executive arm.
"After all, Europe is a woman," Donald Tusk, the outgoing chair of EU summits, told reporters, referring to the ancient Greek mythical figure of Europa who gave her name to the continent.
Lagarde, once France's first woman finance minister and since 2011 head of the International Monetary Fund (IMF), is a strong advocate of female empowerment, although she has no direct, active monetary policy experience.
The biggest task for Lagarde, who had previously denied any interest in an EU job, will be to revive the euro zone economy.
"Christine Lagarde will… be a perfect president of the European Central Bank," Tusk said. "I am absolutely sure that she will be a very independent president…"
Von der Leyen, if approved, would run the powerful Commission, which supervises EU states' budgets, acts as the bloc's competition watchdog and conducts trade negotiations with outside countries. Her presidency would shape policy for the world's biggest trade bloc and its 500 million people.
She once had a reputation as a flawless politician, but Brussels-born Von der Leyen has had a scandal-prone run as German defence minister, mainly over right-wing extremism in the armed forces, gaps in military readiness, and the awarding of arms contracts.
The deal followed a tortuous summit that had leaders nodding off and their police escorts slumped on chairs as groups of leaders huddled in search of an accord.
With a weakened Merkel facing a rebellion by her centre-right European People's Party (EPP) early on in the summit, efforts to push through a deal pre-agreed with French President Emmanuel Macron met stiff resistance from Italy, Poland and others.
They scuppered a plan to install former Dutch foreign minister Frans Timmermans as Commission president.
It was a clear reminder of the risks the EU faces from populists who officials accuse of trying to weaken the bloc's democratic foundations as it struggles with Brexit and challenges posed by Russia, China, Iran and Donald Trump's United States.
Timmermans, who led the Socialists' European Parliament election campaign in May and whose name Macron and Merkel had agreed on at a G20 summit in Japan last week, was the biggest casualty of some 30 hours of negotiations.
In other decisions on Tuesday, Spain's acting foreign minister, Josep Borrell, a socialist, was nominated as the EU's new top diplomat in Brussels.
Macron and Spanish Prime Minister Pedro Sanchez, who had pushed hard for Timmermans, also secured the election of Belgium's liberal caretaker prime minister, Charles Michel, to replace Tusk as chair of EU summits. In that role as European Council president, Michel will be have the job of building compromises between the 28 member states.
Timmermans and Margrethe Vestager, the lead candidate for the liberals in May's parliament election, were put forward as deputies under von der Leyen in the next Commission, which takes office on November 1.