Christine Lagarde has led the International Monetary Fund since 2011.

EU leaders on Tuesday struck a hard-fought summit deal to put women in two of the bloc's most important jobs for the first time.

After three days of bitter wrangling, German Defence Minister Ursula von der Leyen was named to replace Jean-Claude Juncker at the head of the European Commission for the next five years.

Once confirmed, von der Leyen will lead a commission facing a host of challenges, ranging from climate change to disinformation, populism and Brexit.

Former French finance minister Christine Lagarde, who has led the International Monetary Fund since 2011, is to take charge at the European Central Bank.

Summit host and European Council President Donald Tusk confirmed the appointments on Twitter, ending difficult talks that had dragged on since Sunday evening, dogged by division and infighting.

The 60-year-old conservative von der Leyen's name came in the frame for the commission after an earlier proposal to name Dutch social democrat Frans Timmermans ran into insurmountable opposition.

Ursula von der Leyen has been a minister for the past 14 years under German Chancellor Angela Merkel

The package agreed by the 28 EU leaders also sees Belgian Prime Minister Charles Michel take over from Tusk at the European Council of member states, while Spanish Foreign Minister Josep Borrell becomes foreign policy chief, replacing Federica Mogherini.

Von der Leyen, a minister for the past 14 years under German Chancellor Angela Merkel, has been an advocate for closer EU integration, calling for a "United States of Europe".

Except for Michel, the package still needs the blessing of the European Parliament, and several senior figures in Timmermans' centre-left group tweeted their disgruntlement at the proposed ticket.

Brexit Looms

Von der Leyen would take office on November 1 -- the day after Britain is currently due to leave the bloc.

Both candidates vying to take over as British prime minister have vowed to leave on time come what may, so the new commission's first task in office could be to mop up the fall out from a messy "no deal" Brexit.

Von der Leyen had the crucial backing of French President Emmanuel Macron, as well as the support of the Visegrad 4 bloc -- Hungary, Poland, Czech Republic and Slovakia.

This saved von der Leyen from the fate suffered by Timmermans, who was suggested by France and Germany as commission chief instead of the early front-runner Manfred Weber.

A marathon 18-hour negotiating session that began on Sunday evening broke up without agreement on Monday as the V4 plus Italy, where the populist government shares some of the Eastern Europeans' anger at Brussels over migration, refused to countenance Timmermans.

As he arrived at the summit on Tuesday, Czech Prime Minister Andrej Babis slammed Timmermans, who pushed a softer line on migration, as "absolutely unacceptable".

"He has always pushed a migration policy which is unacceptable for us, so this man is absolutely unacceptable and I can't see why the prime ministers of France, Spain, the Netherlands and Germany weren't able to understand," Babis said.

Other countries -- including Ireland, Latvia and Croatia -- also objected on the grounds they had not been properly consulted about the French-German plan cooked up on the sidelines of the G20 summit in Osaka at the weekend.

Familiar Wrangling

Spanish Prime Minister Pedro Sanchez initially stood firm behind fellow Social Democrat Timmermans on Tuesday, but after a morning of bilateral and small group meetings among leaders, the Dutchman's chances were finally buried, according to two sources close to the talks.

Deciding the top jobs was complicated by the fragmentation of the EU political landscape in the May elections to the European Parliament.

The centre-right EPP and centre-left socialist group, the dominant forces in EU politics for years, lost their combined majority in the assembly.

The liberals, which include Macron supporters, are increasingly assertive over the choice of top jobs after they and the Greens made significant gains in the polls.

Protracted wrangling to dish out the EU's top jobs is not new: in 2014 it took three summits to fill the posts.