PARIS—The government of French President Emmanuel Macron resigned on Tuesday in a sign of the unprecedented political gridlock that has gripped France as it prepares to host the Summer Olympics.

Macron’s decision to accept the resignation of his Prime Minister Gabriel Attal—more than a week after he offered it —is mainly a tactical move. It allows cabinet members who successfully ran for seats in France’s recent  snap parliamentary election  to take up their roles as lawmakers in the divided National Assembly on Thursday and vote on the next speaker of the lower house.

That Macron is willing to hamstring his own administration with the Olympics around the corner is a measure of how badly the president’s pro-business party has been weakened in Parliament. France is planning a spectacular opening ceremony on July 26 along the Seine River that will demand a herculean effort to organize and secure.

The cabinet members who resigned Tuesday are expected to remain at the head of their respective ministries as part of a caretaker government with diminished powers. The cabinet will have the authority to look after administrative affairs, but it will be constrained in proposing new legislation, including the annual budget, said Benjamin Morel, a professor of public law at Paris-based Panthéon-Sorbonne University.

“So that gives you some room to maneuver, but limited room,” Morel said.

Macron’s decision to call the elections left the National Assembly divided into three blocs with opposing views. Macron’s party and its allies shed dozens of seats, finishing second to the New Popular Front, a coalition of parties that includes socialists, greens, communists and far-left France Unbowed, and just ahead of Marine Le Pen ’s far-right National Rally in the 577-seat lower house of Parliament.

Macron  penned a public letter  last week that declared “no one won” the election while asking establishment parties, such as the conservative Les Républicains and the Socialists, to band together with his pro-business ranks and form a legislative majority.

Macron’s missive was met with contempt from lawmakers across the political spectrum, many of whom remain flummoxed by his decision to hold the elections in the first place. The New Popular Front, which won the most seats in the National Assembly, has accused Macron of trying to overturn the results of the election, with Jean-Luc Mélenchon , leader of France Unbowed, demanding that Macron “bow down” and appoint a prime minister from their ranks.

The New Popular Front, however, is also in disarray. The leftist alliance was hastily stitched together in the days leading up to the snap elections. That brought together some of the loudest personalities in French politics, none of whom could agree on a candidate for prime minister.

Hardly a day goes by without one leftist party floating a name only to have it swiftly batted down by other members of the alliance.

“If we don’t find a solution in the next few hours or days, it will be a real shipwreck,” Communist Party leader Fabien Roussel said in a TV interview on Tuesday.

In France, the president appoints the prime minister, who is then tasked with forming a government. But if lawmakers are unhappy with the president’s pick, they can put forward a no-confidence vote. If the motion wins the support of at least 289 lawmakers, the government is forced to resign.

When Macron named 35-year-old Attal as his prime minister in January the move was seen as an anointment of the young politician as a successor when the president’s term expires. That image of ministerial competence has now been replaced by one of a government hurtling rudderless toward the Olympics.

Even the expensive cleanup of the Seine River—where athletes are expected to compete in swimming competitions—has become the subject of jokes aimed at the government.

Macron’s sports minister Amélie Oudéa-Castéra donned a full-length wetsuit and swimming cap on Saturday before taking a widely broadcast dip in the river to illustrate its cleanliness. Making her way down an embankment leading into the river, the minister took a pratfall and then tumbled into the Seine’s murky waters, keeping her mouth angled just above the water line.

“It’s really emotional. It’s even soft,” Oudéa-Castéra said, describing the water after the swim. The footage instantly went viral.

The moment appeared to capture the topsy-turvy state of French politics, where Le Pen’s anti-immigrant National Rally managed to garner the most votes in the snap election without winning the most seats. That is because Macron’s ranks and the New Popular Front coordinated in decisive runoff races across the country, pulling their third-place candidates to create head-to-head matches with National Rally and impede its path to power.

Those maneuvers came after Macron took the unusual step of dissolving France’s National Assembly last month in response to the trouncing his forces received from National Rally during European parliamentary elections. The French leader billed the new elections as a moment of “clarification” in France’s yearlong drift toward far-right nationalism.

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