PARIS—President Emmanuel Macron appointed Michel Barnier , the European Union’s former Brexit negotiator, as prime minister in an attempt to find a path out of the political crisis that has gripped the country since the French leader called snap elections months ago.

In choosing Barnier, a 73-year-old member of the conservative Les Républicains party and former French foreign minister, Macron is seeking to preserve his pro-business overhauls. He is also sticking with a paternalistic governing style that has alienated swaths of the French public.

The move comes in defiance of the New Popular Front, a leftist coalition that won the most parliamentary seats in July’s snap elections after campaigning on a pledge to roll back Macron’s unpopular decision to raise the country’s retirement age.

Macron made a massive bet in  calling the snap elections , gambling that voters would rally around his centrist ranks and reject parties from the far ends of the political spectrum. Instead, voters split their votes between a multitude of parties, resulting in the most divided National Assembly in the history of France’s modern republic. Macron’s ranks shed dozens of seats, forcing his government to resign and opening a monthslong debate over which party was entitled to field the next prime minister.

Anyone expecting a humbled, deferential Macron to emerge from the election fiasco has been deeply disappointed. The president rejected a candidate floated by the New Popular Front—a coalition of socialists, greens, communists and the far-left France Unbowed—on the grounds that the leftist candidate didn’t have enough support in the National Assembly to survive a confidence vote.

“The election was stolen from the French people,” Jean-Luc Mélenchon , leader of France Unbowed, said Thursday, calling for protests.

It remains uncertain whether a government led by Barnier can find a majority in the National Assembly. The backing of 58 lawmakers is required to hold a no-confidence motion and 289 votes to pass it and force a government to resign. The New Popular Front, which has 193 seats, has said it would vote against any government led by a right-leaning prime minister. That means the survival of Barnier’s new government will likely depend on Marine Le Pen ’s far-right National Rally, which garnered 126 seats in the National Assembly in July.

“Michel Barnier is no one’s dream, but let’s wait and see,” National Rally Vice President Sébastien Chenu told French TV on Thursday, adding that much will depend on whether Barnier is ready to tackle issues such as immigration, crime and purchasing power.

Barnier’s appointment followed weeks of consultations between Macron and parties across the political spectrum that his office described as unprecedented. The president, his office said, made the decision in accordance with his constitutional duties with the aim of producing a government that is “as stable as possible.”

Barnier is now up against the clock. The deadline to submit next year’s budget to parliament is less than a month away, and investors are on edge over France’s ability to tackle its yawning public deficit.

The spending programs Macron enacted to soften the impact of inflation and the Covid-19 pandemic have blown a hole in France’s public finances in recent years. France’s public deficit reached 5.5% of economic output in 2023. In a letter this week to French lawmakers, reviewed by The Wall Street Journal, former Finance Minister Bruno Le Maire said the country’s public deficit could widen further this year, if the new government doesn’t find billions of euros in savings.

Write to Noemie Bisserbe at noemie.bisserbe@wsj.com and Stacy Meichtry at Stacy.Meichtry@wsj.com