PARIS — President Emmanuel Macron of France lost his bet that he would defeat the far right, not only losing the election to the European Parliament but getting beaten by the populist firebrand he roundly defeated only two years ago, Marine Le Pen.
Even so, it was mostly smiles in the presidential camp on Monday, with upbeat talk of staying the course in domestic policy and satisfied appraisals that the worst had been avoided in Mr. Macron’s party’s relatively narrow loss to Ms. Le Pen’s National Front, now rebranded as National Rally.
That confidence, characteristic of a president only rarely subject to self doubt, could spell trouble down the road, though, in the view of many analysts. On Sunday, the president lost the disgruntled France that spawned the Yellow Vest movement, and those grievances have not disappeared, as the vote for the European Parliament demonstrated.
“There’s a split between the two Frances,” said Jean Garrigues, a political historian at the University of Orleans, between Mr. Macron’s France, “and peripheral France, which considers itself a victim of globalization.”
Now, with the final results of the campaign for the European Parliament that ended on Sunday, the former National Front has anchored itself more than ever as the representative of that France, and as one of the country’s two dominant parties, along with Mr. Macron’s. With their feeble results on Sunday, the traditional parties of the right and left in France have been effectively eliminated from the game.
Mr. Macron had presented himself during the campaign as the country’s only check on the far right; Sunday’s result, for better or worse, demonstrated that it is only a relative one. In France, nearly four million more people voted in this election than in the previous European Parliament election, in 2014, and many of them voted for the former National Front. It received 5.2 million votes, over 200,000 more than Mr. Macron’s party, La République en Marche.
“This is one of Sunday’s major lessons: the National Rally has the ability to vacuum up the protest vote,” Mr. Garrigues said. “That’s major. They’ve firmly fixed themselves in the political landscape.”
Still, the party’s margin was slim — less than 1 percent. It won 23.3 percent of the votes in France, compared with Mr. Macron’s 22.4 percent. The far-right party’s share of the vote was actually slightly less than its proportion of the vote in 2014, when it won 24.9 percent.
For Ms. Le Pen, given up as finished politically after her disastrous debate performance against Mr. Macron at the end of the 2017 presidential campaign sealed a crushing defeat, the outcome on Sunday represented a remarkable comeback.
“Last year they were not even hoping for this,” said Nicolas Lebourg, a historian of the far right in France.
But the margin on Sunday was narrow enough that Mr. Macron will not be forced to give up his cherished project of tighter European integration.
“There’s no collapse, at all, of the president’s European message,” a top adviser told reporters on Monday evening, speaking anonymously according to the rules of the French presidency.
But there are distinct warning signs for Mr. Macron in Sunday’s results. The electoral map shows broad swaths of brown covering the whole country: Ms. Le Pen won more than twice as many departments — a cross between a state and a county — as did Mr. Macron.
She won in the rural, depressed and deindustrialized areas of northern, south-central and eastern France that spawned the six-month Yellow Vest revolt that shook Mr. Macron’s presidency. She won in southeastern France and she won on the Spanish border.
“It’s very impressive,’’ said Bruno Cautrès, a political scientist at the CNRS research center. “It’s taking root in our social, cultural, geographic and political space. And it’s very, very important.”
Sunday’s electoral map “corresponds exactly to the dispersion of the working class on French territory,” said Christophe Guilluy, a leading political geographer. “Macron’s electorate is besieged. They’re living in these new medieval strongholds. And it’s the periphery that is setting the agenda.”
In a series of books, Mr. Guilluy developed the idea of a “peripheral France,” foreshadowing the Yellow Vest revolt.
“They should be worried,” Mr. Guilluy said of Mr. Macron’s supporters. “The big cities, the metropolises, they are transforming themselves into citadels, surrounded by the working classes. This is big, and we saw it in the Yellow Vest movement.”
Mr. Cautrès said that the reaction of the president’s entourage “is as if the crisis is behind us.’’
“But it’s still there, and it nourished the vote of the National Rally,” he said. “One part of French anger was expressed Sunday.”
Mr. Macron remains determined to pursue tighter European integration. He has already begun a series of meetings with the continent’s leaders, playing host to the Spanish President, Pedro Sanchez, on Monday.
In Brussels, Mr. Macron, with perhaps a number of deputies equal to that of the former National Front, in the low 20s, could achieve a position of relative solidity, after aligning with like-minded parties.
“Macron will have the possibility of making a lot of alliances, according to the issue, with a lot of social democrats who follow his line,” said Zaki Laïdi, a professor at Sciences Po, an elite public university. “The Spanish socialists are very close to Macron, and the Portuguese socialists are, too.”
The president’s advisers were even suggesting that finishing second in France did not constitute a setback domestically. “It’s not a failure,” Mr. Macron’s spokeswoman, Sibeth Ndiaye, told an interviewer Monday morning.
“Lovely result, very solid score,” insisted Emmanuelle Wargon, a junior ecology minister. The response to the National Rally’s victory, she said, “is Act II of the presidential term: greater proximity, and greater humanity.”
“We’re ready to unfold the president’s road map,” said Gilbert Le Gendre, Mr. Macron’s parliamentary majority leader, including a comprehensive, and contested, projected pension reform that would consolidate France’s patchwork system.
Those statements suggested the president’s team was simply blowing past the ominous declarations of the far right leaders on Sunday night.
“He can’t continue as if nothing’s happened,” Ms. Le Pen said on French television. “The French have chosen us as the alternative. He won’t pacify the country unless he draws the consequences.”
She called on Mr. Macron to dissolve the National Assembly — he has refused — and institute proportional representation, which she insisted would more accurately reflect her party’s hold on the electorate. It currently has only seven representatives.
Mr. Macron has promised to institute a “dose” of proportional representation, but not enough to satisfy Ms. Le Pen.
“We’ve always called for a peaceful revolution,” she said.
“The face-off between nationalists and globalists is now in place, in durable fashion,” Ms. Le Pen said in a speech to supporters. “And this will condition the future choice in elections.”
If one thing was clear from Sunday’s result, it was that Ms. Le Pen’s forces have come back, perhaps stronger than ever, and are in a competitive position for France’s next presidential election, in 2022.
“What one saw in these Europeans, we’re in the face of a party that could win,” said Dominique Reynié, a political scientist who directs the Foundation for Political Innovation.
“The hatred of him is irrational in its intensity,” he said of Mr. Macron. “The next period is not going to be a cakewalk. We could have a very weakened president, with no moderate opposition.”