German defense minister Ursula von der Leyen was narrowly elected president of the European Commission on Tuesday after winning over skeptical lawmakers.
The 60-year-old conservative was nominated to become the first woman in Brussels' top job last month by the leaders of the bloc's 28 member states, to the annoyance of many MEPs.
The Strasbourg parliament would have preferred a candidate chosen by one of its political groups, but in the end a small majority — 383 members of the 751-member assembly voted — for her.
She will now replace Jean-Claude Juncker as head of the EU executive on November 1, one day after Britain is due to leave the union, and serve for a five-year mandate.
"The task ahead of us humbles me. It's a big responsibility and my work starts now," the polyglot mother-of-seven told lawmakers, thanking all members "who decided to vote for me today."
If von der Leyen had lost, Europe faced a summer of institutional infighting instead of preparing for Brexit, battling Italy over its debt and confronting Hungary and Poland over threats to democratic values.
In a hearing before the vote, von der Leyen promised: "A climate-neutral Europe in 2015. A more social and competitive Europe. A Europe that makes use of its full potential.
"A Europe that has a new push on European democracy and a strong Europe that protects our European way of life."
Von der Leyen has had only a short time since the 28 EU leaders nominated her to win over the main center-right EPP, socialist S&D and liberal Renew Europe blocs she hoped would get her the necessary 374 votes.
In the hours between her speech and the start of voting, party officials suggested she could count on the center-right, almost all of the liberals and maybe two-thirds of the left.
The election was by secret ballot, but the tight margin of victory suggested that she had only won over the pro-European center — and that several mainstream members abstained.
Top jobs package
The nominee announced Monday that she would step down from Angela Merkel's German government this week whatever happened in the vote, underlining her European ambitions.
Five years ago, Juncker received 422 endorsements, and falling far short of that will be seen as disappointing for von der Leyen, who was born in Brussels and was backed by figures like France's President Emmanuel Macron.
Von der Leyen's nomination was part of a package of so-called "top jobs" and outgoing Belgian premier Charles Michel is still in line to head the European Council of EU leaders.
IMF director Christine Lagarde's appointment to the European Central Bank also remains on course, and the French former finance minister announced he resignation from the global body.
In addition to Brexit and the other issues facing the EU, member states are also wrangling over new rules for distributing migrants and refugees after Italy's populist government began to prevent rescue boats from landing.
For that, the commission president will need a reliable majority in Strasbourg, after this year's elections threw up a more fragmented EU parliament than ever.