PARIS — French voters faced a historic choice Sunday between a far-right presidential candidate and a centrist — and they overwhelmingly elected the one who embraced the European Union, immigration, free trade, and LGBTQ rights.

In making Emmanuel Macron the youngest person ever to run France, voters decisively rejected Marine Le Pen, who had alarmed many inside and outside the country by her pointed attacks on Islamic fundamentalism, immigration, hostility to Europe, close ties to Russia, and socially conservative platform.

"Europe and the world expect us to defend the spirit of the enlightenment that is threatened in so many places," Macron told a rapturous audience gathered in front of the glass pyramids outside Paris’s Louvre museum. He promised to ensure there would be no reason to vote for “the extremes” after his five years in office.

"This challenge before us is huge,” he said, “and it will require us to continue to be brave."

For her part, Le Pen was quick and concise in her concession speech, “We have been designated the leading opposition force in this second round,” she said. She wished Macron success. “The French have elected a new president and opted for continuity.”

In a sign of how much fear she had aroused, former President Barack Obama took the highly unusual step of formally endorsing Macron. The 39-year-old, who had never previously run for elected office, also drew support from politicians across the French political spectrum, including virtually all the candidates he defeated in the election’s first round.

In the end, the final results were in line with what pollsters had predicted: a healthy Macron win. The former investment banker claimed 65.8 percent to Le Pen’s 34.2 percent, according to numbers announced by France2 at 8 pm Paris time as the polls closed. Those percentages closely match that of the last poll produced Friday by Ipsos. Indeed, a cheer went up that rippled through the streets when the announcement came at exactly 8 pm, Paris time.

It was the third consecutive defeat for a European far-right populist party, including Geert Wilders’s high-profile loss in the Netherlands back in March. But those who support such populist extremist policies are likely to remain optimistic. Le Pen’s far-right nationalist party won the highest number of votes it has ever received in modern French history, and, like in the Netherlands, the terms of the debate — especially on immigration — tacked sharply to the right during the presidential campaign.

In a recognition of how important this election felt to Europeans, notes of congratulations came swiftly from around Europe. German Chancellor Angela Merkel and Macron had a “very warm” 10-minute phone call, according to reports. Steffen Seibert, a press representative for the German government, tweeted that the win was a “victory for a strong and united Europe.”

Félicitations, @EmmanuelMacron. Votre victoire est une victoire pour une Europe forte et unie et pour l'amitié franco-allemande. — Steffen Seibert (@RegSprecher) May 7, 2017

Greece’s Prime Minister Alexis Tsipras called the Macron victory “an inspiration,” and the president of the European Union, Jean-Claude Juncker, also tweeted his congratulations.

The past weeks have been characterized by a stark division between visions of France: Macron ran on a platform of optimism that called for embracing Europe, globalization, immigration, and freedom of movement between countries. Le Pen presented a dark, pessimistic, nationalist, and xenophobic image of the country, a nation with closed borders and a much diminished relationship with Europe.

That contrast was never clearer than during the presidential candidates’ final debate on Wednesday night, which devolved into a verbal brawl filled with name calling and finger pointing.

French voters have been grappling with several nationwide issues: 10 percent unemployment (a number that skews up to 25 percent for the youngest workers), widespread dissatisfaction with the mainstream political parties that led to their out-and-out trouncing in the first round of the election, and the aftermath of several high-profile and devastating terror attacks. France was at a very literal crossroads. Many were unhappy with either choice, and all week Parisians wrung their hands over fears of abstention voters. The concern was if those numbers were high enough, their absence would benefit Le Pen.

As political scientist Catherine Fieschi told Vox just before the vote, “A Macron-Le Pen run off is a real test of two visions of France: open, future oriented and ready to lead, versus scared, closed and failing to take on its role as a European power.”

Indeed, while there may be euphoria in certain circles Sunday night, what this election has shown quite starkly is that France is divided like never before. Macron’s work is laid out for him, not least because his entirely new political party will now face legislative elections in early June and that will determine how much of his policies will actually be able to be enacted.

A populist candidate campaigned on fear and anger. Sound familiar?

Like most right-wing populists of Europe, Marine Le Pen used the fear of what she called the “twin totalitarianisms” of globalization and Islamism to propel her campaign.

Her largest success came from the working class in France’s Northeast, a formerly industrial area of factories that have shuttered over the course of the past few decades, and on the southern Mediterranean coast, which — especially in cities like Marseilles — has a large immigrant population from northern and sub-Saharan Africa.

Just as the second round of campaigning began, Le Pen made a showy appearance at a Whirlpool dryer factory, which is scheduled to cut 280 jobs and move them to Poland. The move was meant as an attack on both free trade generally and Macron personally: Whirlpool has, until now, been based in Amiens, the town Macron is from. Le Pen, borrowing from the lesson of President Donald Trump, promised those workers that she would save their jobs, and that Macron would not.

Indeed, after the first-round election, the map of France looked eerily like that of the United States in its divisions between rural and urban areas, and its population’s sense of what the future might bring. Le Pen picked up 7.7 million voters, an unprecedented number for such an extreme right-wing candidate.

But her real success in this race had its roots in an effort she began in January 2011 when she took over the National Front and began to rebrand the party. Founded by her father, Jean-Marie Le Pen, in 1972, the National Front had always been a marginal, xenophobic party, marked by anti-Semitism, homophobia, and xenophobia.

Le Pen launched a campaign to purge the party’s demons — literally dediabolisation in French — and expelled her father from the party ranks. She extended a hand to women, to Jews, and to the LGBTQ community, promising to protect all three from fundamentalist Muslims that she said were opposed to France’s secular values and prepared to use violence against all three groups.

She tried to draw herself as the defender of democracy, of French values, of France itself, and set up a stark contrast between that picture and radical Islamic fundamentalism and immigration.

Le Pen was successful enough in both covering up the party’s 40-year-old racist stain and pitching herself as a savior against globalization and Islamism, that many young voters in France in round one threw their votes to her. In round one of the election, among 18- to 24-year-olds, she picked up 21 percent of that vote, only beat out by radical left populist Jean-Luc Mélenchon, and she did extremely well in the 25- to 34-year-old set, gaining 24 percent of those votes.

A far-right party had a real chance at winning the race

Unlike in 2002, the last time the National Front made it to the final round in a presidential election, the so-called Republican Front of voters, politicians, and cultural figures who vocally called to stop Marine Le Pen was notably weaker in 2017.

In 2002, “the party was far more associated to the post-war extreme right — where among the founders of the party, you had former collaborationists, people who were nostalgic of Vichy,” the collaborationist government that had worked with the German occupiers, and “some of them had fought with the German Nazis,” Nonna Mayer, a French political scientist, explained to Vox in her Paris office the week of the election.

Another factor that undermined the Republican front, Mayer said, was that the traditional “left is completely disrupted. The left is in ruins.”

The Socialist Party, in other words, had been left in shambles after the wildly unpopular presidency of François Hollande, who left office with just a 4 percent approval rate. That laid the groundwork for a mass exodus from the traditional left, and a fracturing of that voter base.

Other French voters simply appeared to have wanted a change from the status quo, which had been dominated by the two establishment parties since the founding of the modern French state.

“You have a very, very strong rejection of the political class in general,” Mayer said, which led to the creation of “Ni-Ni” or “neither nor” voters.

A historic high of 25.3 percent voters left their ballots blank or abstained altogether. Those types of voters were the basis of much concern this week, as what seemed like an ever-increasing number of voices announced they were neither for Macron nor for Le Pen. That added so much uncertainty into the final days of this campaign that most French publications had covers urging readers to vote rather than abstain.

Indeed, the first hour after the win, not everyone rejoiced. “It’s all political theater,” said a 59-year-old bar owner in the Marais named Thierry who said he had not liked the choices on the ballot; a few of his patrons echoed the sentiment.

Overall turnout was estimated to be the lowest in decades. In France, the second and decisive round normally has higher turnout than the initial round. This time, by contrast, it was higher.

All of that gave Marine Le Pen a narrow window of possibility to win this vote.

She was helped, along the way, by exploiting the concerns of a country that had been hit hard by terrorist attacks in the past two years — most dramatically twice in Paris, and in Nice.

“France, land of human rights and freedoms, was attacked on its own soil by a totalitarian ideology: Islamic fundamentalism,” Le Pen wrote in the New York Times after the attack on Charlie Hebdo magazine in Paris in January 2015 left 12 dead. “It is only by refusing to be in denial, by looking the enemy in the eye, that one can avoid conflating issues. Muslims themselves need to hear this message. They need the distinction between Islamist terrorism and their faith to be made clearly.”

And yet there were clear signs that much of France had deep concerns about Le Pen. Mayer noted that final polls showed that some 58 percent of the French public considered the party “a danger for democracy,” up from just 48 percent in 2013 and 2014. Le Pen’s very success sparked real fears of how far she might be able to ascend.

That’s because, at root, her campaign remained about France for the French, a vision that promised to dramatically curtail immigration, and even cut it off entirely for a time. It also predicated its vision on a demonization of Islamic fundamentalism and immigration that many were uncomfortable with.

Russian hackers made a last-minute attempt to sway the race. It failed.

Polls had consistently shown Macron with a wide lead, but the final day of the campaign got a jolt after a massive hack on the Macron campaign just over 24 hours before voters went to the polls on Sunday. The attack, widely attributed to Russian sources, dumped some 9 GB of data onto a sharing site and was picked up and broadcast widely across social networks under the hashtag #MacronLeaks.

In France, candidates may not campaign in the final hours leading up to the ballot box, a way of quieting down the media barrage that accompanies the weeks around an election. The Macron campaign was able to put out a single statement. The attack, they said, was clearly planned “to sow doubt and misinformation.”

“Coming in the final hours of the campaign, this operation is clearly a matter of democratic destabilization, as was seen in the United States during the last presidential campaign,” the statement continued.

The French public seemed largely unimpressed by the hack, and there’s no evidence it impacted the results.

And yet the hack harked back to two issues raised at Wednesday night’s debate — security and France’s relationship with Russia.

That night, Marine Le Pen spent a significant amount of time trying to convince the public that Macron would be soft on terror and a pawn of Angela Merkel. (“France,” Le Pen said in a particularly biting moment, “will be run by a woman — me or Angela Merkel.”)

Macron, in turn, mocked Le Pen’s ideas of shuttering borders, expelling immigrants suspected of terror ties, and creating a security apparatus with greater power — and her links back to Vladimir Putin, whom she visited during the campaign and whose party had received direct financial support from the Russian autocrat.

“I will not accept to have my behavior dictated by Mr. Putin, and that's the difference with Mrs. Le Pen," he said at the debate. "We will not submit to Russia or Mr. Putin's values, as they are not the same values as ours."

Macron was never supposed to be here. He’s got a lot of work cut out for him.

Macron managed to move to the front of the original pack of French presidential candidates by happenstance, luck, and pedigree.

Macron benefited from the disintegration of the Hollande presidency and his early decision to strike off on his own, with a brand new party, rather than allow himself to be weighed down by the Socialist Party’s increasingly bad reputation. The Socialist candidate, Benoît Hamon, was never able to break through the malaise associated with Hollande. Finally, François Fillon, the conservative Republican Party leader long seen as the frontrunner, was hit with a financial scandal that caused his candidacy to implode.

“People are exhausted,” says Catherine Fieschi, the political scientist. Macron, she added, has a “mountain to climb in terms of breathing some vitality back into democratic life. Because the campaign drained France of that.”

He faces a country that backed him by default, and he fronts a party that has never held office. That could come back to haunt him in early June when France elects a legislature that Macron will need to work with, and a prime minister who will wield much power. He best get some rest. Even after defeating Le Pen, there’s much work to be done.

“The election has crystallized [the country’s] divisions,” said Fieschi, “and at the same time wiped out the traditional parties who have normally dealt with them. So it means that this could be a real moment of reinvention, if Macron can seize it.”

She added, “But at 65 percent, Macron is well placed to deliver on the expectations of all those who voted for him.”

This story is part of a Vox collaboration with the Pulitzer Center on Crisis Reporting about the historic French elections.