French President-elect Emmanuel Macron holds hands with his wife, Brigitte, during a victory celebration outside the Louvre Museum in Paris. (Thibault Camus/AP)

Three years ago, hardly anyone knew his name.

But in a once-unimaginable scenario, Emmanuel Macron — at 39, the boy wonder of an aging political establishment — won the French presidency Sunday with a tidal wave of popular support. He will soon be France’s youngest head of state since ­Napoleon Bonaparte as well as its first modern president who does not belong to either of the center-left or center-right parties that have run this country for 60 years.

After the Brexit campaign’s success in Britain and Donald Trump’s upset victory in the U.S. presidential election, ­Macron’s triumph was billed as having slowed the global tide of anti-establishment populism. In the vote’s second and final round, he defeated Marine Le Pen, the leader of the far-right National Front, an anti-immigrant party tainted by the perception that it is tolerant of anti-Semitism and Nazi nostalgia.

“I will fight with all my strength against the division that is undermining and defeating us,” Macron said just after the results were announced. “For the next five years, I will serve on your behalf with humility, devotion and determination.”

Macron’s story is of a highly improbable ascent in a system that typically rewards entrenched political dynasties.

(Adam Taylor,Jason Aldag/The Washington Post)

“It’s entirely unprecedented in the Fifth Republic,” said François Heisbourg, a well-known French defense expert who has advised Macron on security and terrorism issues. “It’s extraordinarily unusual, the way he has broken through the system — coming from nowhere.”

[Macron campaign says its emails have been subjected to “massive” hacking]

Macron, who has never held elected office, has now been elected to one of the most powerful executive positions in the Western world and will be the leader of Europe’s second-largest economy. He did it, analysts say, through a combination of luck and a campaign message attuned to a new political moment.

In France, 2017 proved an ideal year to run as an independent candidate. A rare political vacuum emerged, and Macron — a former Socialist economy minister who stepped down from his post in July — was able to take full advantage.

With the public frightened by a slew of terrorist attacks by Islamist extremists, and with the unemployment rate in double digits, France’s Socialist Party, under President François Hollande, sank to historic levels of unpopularity. Hollande promised in December not to seek reelection, but his Socialist stand-in, Benoît Hamon, was eliminated in the election’s first round, winning a meager 6.35 percent of the vote.

France’s mainstream conservative party, Les Républicains (the Republicans), was undermined by a spending scandal involving François Fillon, its contender. Once the undisputed favorite, Fillon suffered a fatal blow after Le Canard Enchaîné, a French satirical newspaper, accused him of funneling about 900,000 euros ($990,000) of public funds to his wife and children for work they never did.

French President-elect Emmanuel Macron and his wife, Brigitte, celebrate on the stage at his victory rally near the Louvre. (Philippe Wojazer/European Pressphoto Agency)

Macron perceived that the “new divide” among French voters was not between left and right but rather between an open and closed society, Heisbourg said.

Defending an open, multicultural society was a central component of En Marche (Onward), the movement Macron launched in 2016. “Globalization can be a great opportunity,” he said at one point on the campaign trail. “There is no such thing as French culture,” he said at another. “There is culture in France, and it is diverse.”

The great French novels are often stories of ambitious young men from the provinces who come to Paris to seek their fortunes. For many, Macron is no exception. The literary son of doctors from provincial Amiens, he graduated from France’s elite École Nationale d’Administration, the traditional breeding ground of presidents.

Some in the French news media have placed the first sign of Macron’s formidable ambitions in, of all places, his love life — namely, in his dogged pursuit of his wife, Brigitte, his former high school teacher and a woman 24 years his senior. As Brigitte Macron told a French documentary maker last year, “Bit by bit, he defeated all my resistance, in an amazing way, with patience.” The candidate showed the same persistence in capturing the Elysee Palace.

[Macron is 39 and his wife is 64. French women say it’s about time]

“I have known failures, sometimes bitter, but I have never allowed myself to turn away,” Macron wrote in his 2016 book “Révolution.”

That doggedness — along with a calculating eye for useful associations, critics say — brought him into contact with many prominent French thinkers and government officials, who then helped him advance.

In the late 1990s, while still a graduate student, Macron worked as an assistant to Paul Ricoeur, a prominent French intellectual and writer; by the mid-2000s, he was working for the Finance Ministry, on a commission dedicated to stimulating economic growth. It was there that he met Jacques Attali, a prominent economist and Parisian power broker who many say later ushered Macron along a speedy path to the highest echelons of the Hollande administration.

In an interview, Attali, who has also served as an adviser to the Macron campaign, rejected out of hand the idea that the candidate was mainly a gifted networker.

“He would be where he is today with or without my help,” Attali said.

If Macron’s ambition has led him to considerable success, it has also earned him enemies — including, some say, Hollande, whom he served as economy minister but then abandoned to launch his party.

“Emmanuel Macron betrayed me methodically,” Hollande said last year, according to the daily newspaper Le Monde.

Jean Pisani-Ferry, another Macron adviser and the author of much of the candidate’s platform, brushed off the comment.

“He launched another politics, created a new movement. Political life wouldn’t exist otherwise,” Pisani-Ferry said in an interview.

Despite the improbable nature of Macron’s victory, France’s new president will face a considerable challenge as he attempts to form a government. Given that he has no party structure behind him, he will be deeply affected by the results of the parliamentary elections, scheduled for June.

“There is huge uncertainty regarding the parliamentary elections to come, because France’s main political forces were largely absent in the second round — the traditional right wing, the Socialists and the far left,” said Patrick Weil, a leading French legal scholar and historian. “Now they are frustrated, and they are ready to take their revenge in the legislative elections.”

In the past, when the National Front made it to the final round of the presidential election, the rest of the political spectrum united in opposition to the extreme right. But this year, certain politicians hesitated to back Macron in the final round — notably the far-left Jean-Luc Mélenchon. Many voters also opted to abstain or to cast blank ballots.

“You might have higher mobilization for the parliamentary elections than usual, which, given turnout in the presidential election, could mean a higher legitimacy for the parliament than for the presidency,” Weil said.

Read more:

A youth revolt in France boosts the far right

The dark history at the heart of the French election

How Merkel’s efforts to save Europe may lead to its undoing

Today’s coverage from Post correspondents around the world

Like Washington Post World on Facebook and stay updated on foreign news