PARIS - France was supposed to be next.

Following the seismic shocks of the Brexit referendum and the victory of Donald Trump, commentators worldwide fixed their sights on the French presidential election as the next potential populist upheaval. But it never happened. Emmanuel Macron, the centrist, pro-European Union candidate, demolished Marine Le Pen, the far-right ultranationalist, in a landslide victory.

"Everyone told us it would be impossible," Macron declared Sunday of his victory, to a crowd that erupted in cheers. "But they did not know France."

Why did right-wing populism fall flat on its face in France, a country that would seem such a fertile breeding ground?

The country, after all, has had double-digit unemployment for years. It has been rocked by terrorist attacks - perpetrated mostly by Islamist militants. In the aftermath of that violence, there has been a strong anti-immigrant backlash.

But compared with Britain and the United States, analysts say, there were two important factors that helped explain why the center held in France: the country's history and a lower level of inequality.

French voters were clearly ready to back a political outsider. But for many, the National Front - Le Pen's party - did not represent change in the same way that Trump did in the United States. Co-founded in 1972 by Le Pen's father, the convicted Holocaust denier Jean-Marie Le Pen, the party has existed on the margins of public life for decades. Its identity is well known.

"The rejection of Le Pen was a basic rejection of the extreme right and its racist, anti-Muslim sentiment," said Vivien Schmidt, an expert in French and European politics at Boston University. "In a country that's already experienced the extreme right in power before, you can put the rejection of Le Pen in a direct line with the rejection of Vichy."

The Vichy government assumed power after France fell to Nazi Germany in 1940. Although Vichy is infamous in France for having complied with German demands to deport tens of thousands of Jews to death camps, the regime also passed a slew of anti-Jewish regulations on its own.

Although the younger Le Pen sought to change the National Front's reputation for anti-Semitism and racism, her efforts were undermined by revelations in French media that several of its high-ranking members had committed variations of Holocaust denial. In a poll conducted before the election, 58 percent of voters said that the National Front presented a "threat to democracy."

At Macron's victory party outside Paris's Louvre Museum, many described their primary emotion as relief, rather than excitement.

Simon Moos, 18, a high school student, braved the unseasonable chill to catch a glimpse of Macron at the rally, even though he had not supported the candidate in the first round of the election.

"I'm relieved, honestly," he said. "Really relieved. France will remain France. I'd cut my throat before Le Pen was president."

In terms of economics, analysts said, the populist platform was likely less appealing in a country where a strong, centralized state has maintained a variety of social benefits.

Despite a recently widened gap between rich and poor, France still trails the ratios of Britain and the United States, according to statistics from the Organization for Economic Cooperation and Development.

In the 1980s, Ronald Reagan in the United States and Margaret Thatcher in Britain, both conservatives, began implementing reforms intended to stimulate economic growth, including deregulation, privatization, free trade, fiscal austerity and cuts in government spending. Some of these ideas were ultimately incorporated in the platforms of their more liberal successors.

France adopted some of those "neoliberal" reforms in the 1980s. But it never relinquished its statist economy and especially its extensive system of welfare protections in the same way, said Daniel Stedman-Jones, a historian and the author of an acclaimed study of neoliberalism.

"It may be no surprise that we see this populist backlash against globalization and immigration in the U.K. and the U.S., because these were the countries where Thatcher and Reagan introduced the most radical neoliberal policies," said Schmidt. "You had them in France to some degree, but never to the same extent."

Although Marine Le Pen was a staunch defender of France's famous welfare state, she did not benefit from a swelling tide of protest votes. Le Pen received roughly 34 percent of the ballots cast, but a larger percentage of voters abstained or turned in blank ballots.

"People may be feeling insecure and left behind, but the situation is not nearly as bad" as in other countries, Schmidt said.

There is also the reality that the National Front did not have a monopoly on the populist market, others said, pointing to the astonishing rise of Jean-Luc Mélenchon, a far leftist who advocated withdrawing from NATO. He did not make it past the first round.

"In France, we have two populisms - one of the extreme right, but another of the extreme left. To understand this, you have to understand the history of France," said Michel Wieviroka, a sociologist. "This is essentially the legacy of the old Communist Party. Britain never had that same history, and neither did the U.S."

Perhaps the most visceral challenge to France's political establishment in recent years has been terrorism. More than 230 people have died here in terrorist attacks in the last two years, many committed by men from immigrant backgrounds who held French or other EU passports.

Despite the rise in popularity of Le Pen's anti-immigrant platform in the aftermath of these attacks, most French voters seem to have rejected her appeals to sharply reduce immigration, at least for the moment.

Antoine Leiris, a French journalist, lost his wife, Hélène, in the Islamic State attack on the Bataclan concert hall in Paris in November 2015. In a best-selling book, Leiris addressed the extremists who murdered his wife: "You will not have my hate," he wrote.

The same message, he said in an interview, emerged from the 2017 election.

"Despite these horrible attacks, the French chose intelligence and wisdom," he said.