PARIS — Emmanuel Macron has been elected the next president of France, defeating far-right candidate Marine Le Pen and ending, for now, what had seemed a tidal wave of populism and nativism sweeping the West. Macron won by a landslide according to official counts, with 65.68 percent of the valid ballots versus 34.32 percent for Le Pen.

In some respects, this critical election had come to appear a proxy battle between current U.S. President Donald Trump and his predecessor Barack Obama, both of whom weighed in during the campaign.

Trump favored Le Pen’s anti-immigrant, anti-Muslim, closed-border protectionist positions, which would have gone a long way toward destroying the European Union and NATO as we know them. He called Le Pen the “strongest” candidate on security issues, as he sees them. (Trump tweeted his congratulations to Macron in unusually stiff language, and the White House offered formal felicitations, while Germany's Angela Merkel, Canada's Justin Trudeau and Britain's Theresa May spoke with Macron directly within minutes of the announced results.)

Le Pen had enjoyed conspicuous support from Russian President Vladimir Putin, who received her at the Kremlin during the campaign, and who is suspected of links to the hackers who tried, at the last minute, to bring down Macron. According to a Macron spokesperson, Putin sent a congratulatory "message" to Macron on Monday morning.

Obama, meanwhile, actually taped an endorsement of Macron, who is much more moderate and pragmatic than Le Pen, and shares many of Obama's core beliefs. Among them: the need to act to slow climate change. A video that Macron released in February, speaking in English to American researchers and scientists, telling them they should come to France rather than suffer the hostility of the Trump administration, has gone viral since the Macron election.

The president-elect supports reforms on immigration issues, including much stronger European borders, and he takes a tough stand on terrorism, of course, but it is untainted by the thinly disguised racism integral to the history of Le Pen’s National Front party. Macron supports reforms to the European Union, not its dissolution and destruction, and is also a firm believer in the North Atlantic Alliance, which Trump used to call "obsolete," then decided it was no longer so.

As French political scientist and author Dominique Moïsi says, succinctly, Le Pen (and many other populists) represent “anger, fear, and nostalgia.” Macron has presented himself as a man with a vision for the future, one built on reform, not upheaval, focused on the economic and security imperatives of the 21st century.

But one might well ask, where did this 39-year-old wunderkind—the youngest leader of France since Napoleon—actually come from? In an era of what seems relentless polarization, how did he pull together the forces of centrism and pragmatism to win such a convincing victory?

It was barely more than a year ago that Macron announced the formation of his political movement, En Marche! (Onward!), which not only was not a traditional political party, but hoped to siphon support from both the traditional Socialists and the traditional conservatives, now known as Les Républicains. He was neither one, nor the other, he said, and when he started his march toward the French presidential palace, the Élysée, it seemed at best quixotic.

But, Macron was never really an outsider, and his bitter opponents on both left and right often potrayed him as nothing more than a front man for the stagnant status quo. They claimed Macron benefitted from the quiet—some said nefarious and conspiratorial—backing of the wildly unpopular outgoing Socialist president, François Hollande. Because Macron also worked for a few years as an investment banker with Rothschild, he was portrayed as well as a tool of global financial interests. Were there hints of anti-Semitism in the Rothschild references when Macron (a Roman Cahtolic) was attacked? Of course there were.

Where might one begin with the story of Macron’s rise?

Possibly with his upbringing in the provincial northern French city of Amiens, where according to his own campaign autobiography he was a child whose parents, both doctors, were rarely at home; who was raised by his beloved grandmother. He buried himself in books, reading and rereading French classics, and seems to have had few friends his age.

Indeed, when he was about 15 he fell in love with—and some years later married—his drama teacher, who was 24 years his elder.

Or, one might start with Macron’s stellar academic career: he always seemed to be the smartest kid in the class, even at the prestigious École Nationale d’Administration (ENA), which traditionally produces many of the top civil servants, business leaders, and indeed presidents of France. He was spotted by Jacques Attali, once an éminence grise advising French President François Mitterrand in the 1980s, who gave him a choice assignment working with a commission looking for ways to increase economic growth in France. That helped lead to the job at Rothschild, and then to a position advising President Hollande, who made Macron minister of the economy in 2014.

If one is to look at when and how the Macron movement began, that ministry at Bercy on the edge of Paris probably is the place to start. Because surrounding Macron there were some of the best and brightest minds in French administration and politics. Many of them had been part of the team of another presidential hopeful a few years earlier: Dominique Strauss-Kahn.

DSK, as he was known, had gone on from the economy ministry to serve as head of the International Monetary Fund in Washington, but was widely touted as the man sure to win the top job in France in the 2012 elections. By the spring of 2011, his path to the Élysée had seemed bright and open. Then, while on a visit to New York City, he was arrested, accused of assaulting and raping a hotel maid. The charges eventually were dropped, and he settled a civil suit out of court, but the flood of revelations about his private life—sordid even by the tolerant standards of France—ended his career.

When members of DSK's old team crossed the path of Macron at Bercy, they knew they had another chance. And by the time Macron resigned from the economy ministry in 2016, he knew he had the core of his movement. The march of En Marche! had begun. Many who were there at the beginning describe it as a sort of a political start-up.

In the months that followed, Macron proved an attractive candidate for the French mainstream media (which loathed Le Pen), and his strongest opponent, Les Républicains candidate François Fillon, fell prey to a scandal: after Fillon announced he would do away with 500,000 public sector jobs in the name of much-needed reforms, he was put under formal investigation for putting his wife and children on the public payroll for work they either did not do, or were not qualified to do, to the tune of $1 million.

To this day, some Fillon supporters are among the most bitter opponents of Macron, sure that President Hollande’s "black cabinet” must have leaked the scandalous information about their candidate.

The level of discontent with this election was evident. Some 25 percent of registered voters did not cast ballots (although their motives on a rainy three-day weekend might have been as slothful as political), and almost 12 percent of those who did drop their ballots in the boxes either left them blank or spoiled them in one fashion or another. As a result, when counting the numbers of votes for the candidates against the total number of registered voters, as the Macron camp is well aware, the figures suggest troubles ahead: Macron got the support of only 43.75 percent of the total number of registered voters, while Le Pen got 22.86 percent. And many on the left and the right who voted against Le Pen say they are committed to fighting against Macron's movement in the legislative elections coming up next month.

But for the moment, among many in France, Europe, the United States and the world (including the financial markets) there is a huge collective sigh of relief. The outsider with all the inside connections has won. Now what he has to do is govern an angry, fearful, nostalgic country, and prove things really can be better than they were before.

This article was last updated at 6:20 a.m. EDT, Monday, May 8, 2017