PARIS — French voters on Sunday rejected the two political parties that dominated France’s post-World War II political life, pitting an anti-immigrant firebrand against an unconventional centrist in a presidential election that could determine the future of the European Union and France’s place in the world.

By picking the pro-EU former economy minister Emmanuel Macron and National Front leader Marine Le Pen to advance to the decisive May 7 runoff, French citizens set up a stark choice. Now there will be a battle between a contender who wants to seal France tight against the tides of globalization and another who seeks to strip away even more barriers with the rest of the world.

The victor could determine whether the international alliances that formed the backbone of the post-World War II West will strengthen or be shattered by the force of nationalism. Le Pen has said she will seek to pull France out of the European Union, a move many European leaders think would doom the 28-nation bloc, and she would rekindle relations with Russian President Vladimir Putin after years of strife between Russia and the West. Macron has called for a more muscular European Union where Europe’s richest nations would do more to prop up their poorer neighbors.

If Le Pen wins, she will continue a global string of ballot-box revolutions that began last year with the British decision to leave the European Union and continued with the election of Donald Trump as U.S. president. With her fierce anti-immigration agenda and her vow to keep France for the French, she could be a Gallic counterpart to Trump. But if Macron is triumphant – and polls suggest he will be, by a 24 percentage point margin – it would be a further barrier to transatlantic disruptions, at least for now, after Dutch voters rejected a far-right leader in March elections.

At the jubilant Macron rally in Paris, the centrist candidate who was Socialist President François Hollande’s economy minister told his supporters that France would prosper in a revitalized European Union.

“I’ve heard the anger, the fears of the French people, their fear of change,” the 39-year-old Macron said, winking at his cheering audience. “I want to be the president of all patriots against the nationalist threat.”

At Le Pen’s rally in Hénin-Beaumont, a northern French town hard hit by factory closures, the modest assortment of soft drinks and snacks gave it more the feeling of a country fair than the celebration of an ascendant presidential campaign – exactly the everyman image Le Pen has sought to project.

“What is at stake in this election is a referendum for or against lawless globalization,” Le Pen told the cheering crowd. “Either you choose in favor of a total lack of rules, without borders, with unlawful competition, the free circulation of terrorists, or you make the choice of a France that protects.

“This is truly what is at stake. It is the survival of France,” she said.

The vote came after a turbulent campaign in which long-time pillars of France’s political establishment were either rejected by voters or discredited by scandal. Hollande, the most unpopular of all postwar French presidents, said he would not seek reelection. His most prominent Socialist successor lost to a primary challenger. So did the former center-right president, Nicolas Sarkozy.

The early front-runner in the race, François Fillon, a right-wing challenger who sought a Margaret Thatcher-style overhaul of France’s economy, fell prey to a nepotism scandal.

With 94 percent of the vote counted, Macron led the field with 23.8 percent of the vote. Le Pen followed with 21.7 percent.

Many voters said they were opting for the least bad of an unpalatable range of options.

“I want nobody, and it’s very complicated. I just don’t want to see the extremes,” said Emma Lacour, 42, who voted Sunday in the upscale Saint-Cloud suburb of Paris, where conservatives usually dominate. “I decided two minutes ago, and I’m not very happy,” said Lacour, who was too dispirited to say who she picked as she walked out of the ornate 19th-century city hall that held the voting station.

Thursday’s attack on police officers patrolling Paris’s glittering Champs-Élysées boulevard was the final, bloody exclamation point in a campaign that often revolved around fears of terrorism and immigrants. One officer died and two were wounded by a gunman who pledged loyalty to the Islamic State.

Filled with fresh worries about security, voters may have been drawn by Le Pen’s growling message about refugees and terror suspects. Macron, a newcomer who is far more conversant with boardrooms than he is with situation rooms, has sought to boost his security bona fides.

A former investment banker and a product of France’s elite educational institutions, he has described himself as a candidate neither of the left nor the right, and he has never held an elected office. His agenda marries social liberalism with proposals that would dilute France’s traditionally robust protections for workers. And – despite prevailing winds that make pro-EU sentiment an unlikely campaign strategy – he has embraced the union and said he wants to make it stronger.

“I’m hoping for the renewal of the French political scene,” said Catherine Grevelink, 56, who oversees legal issues at a bank and voted for Macron in Saint-Cloud. “He’s very intelligent. Now we have to see how this comes out as he governs, if he is president.”

Either of the winning candidates would face questions about governing, since neither has a party structure in France’s parliament. Macron’s movement is too new to have any lawmakers, and Le Pen would face steep challenges in capturing a majority of the National Assembly in elections scheduled for June 11.

That could potentially be a brake to her more ambitious plans, such as taking France out of the European Union. EU membership is enshrined in the constitution, and any change would require approval in both houses of parliament.

Sunday’s result is a vindication of Le Pen’s years-long strategy to destigmatize her party after decades in which it lurked on France’s far-right fringe. Her father notoriously described the Nazi gas chambers as “a detail” of World War II. But Le Pen, 48, sought to make inroads among France’s large Jewish community and also depicted herself as the single true defender of French workers.

“The laws are there already, but no one applies them, as the attack in Paris showed,” said Martine Le Roy, 62, a retired insurance worker from Hénin-Beaumont. She said that she was supporting the anti-immigrant, hardline Le Pen because she was worried about security.

Even as Macron and Le Pen advanced to the next round, the sheer uncertainty in the lead-up to the Sunday’s vote was a measure of the unmooring of French political life.

“We’ve had two consecutive presidents, Nicolas Sarkozy and François Hollande, very different orientations, very different policies, but still we have the same economic problems,” said Bruno Cautrès, who studies voting behavior at the Center for Political Research at Sciences Po. “It has been one of the best arguments of Marine Le Pen: ‘Why not me?’”

Although most opinion polls suggest that Macron would win at least 60 percent of a head-to-head vote against Le Pen, an unforeseeable event – like a large-scale terrorist attack — could shift votes in Le Pen’s direction. And the far-left candidate, Jean-Luc Mélenchon, who electrified crowds of young voters with his soak-the-rich message, notably held back Sunday from asking his supporters to vote for Macron in the runoff, raising the prospect that a large portion of them – 19.4 percent of Sunday’s voters – could stay home or even vote for Le Pen. Backers of other candidates could also swing to Le Pen.

If Le Pen ultimately falls to Macron, she will still have taken the far-right further than any prior candidate in one of Europe’s pillar nations. If her rival is elected but fails to live up to expectations, she could seize the presidency in the next election in five years, analysts said.

“If she does well, she could be even stronger in 2022,” said Jean-Yves Camus, an expert on the French far-right at the French Institute for International and Strategic Affairs.