Jean-Marc Ayrault, the current prime minister, gave a somber speech on Sunday evening as the votes were still being counted in some places. “Tonight is a moment of truth, and this is a defeat for the government,” he said.

Image Anne Hidalgo, elected mayor of Paris, one of just a few wins Sunday for the Socialist Party. Credit... Philippe Wojazer/Reuters

“The midterm elections are an opportunity for citizens to send a message. This message is clear and must be heard,” he said.

Mainstream conservatives from the Union for a Popular Movement party expressed satisfaction with their party’s showing.

“The message that the French sent us this evening is very clear: They expressed a scathing rejection of the left,” said Jean-François Copé, the party’s leader. “The explosion of insecurity and unemployment was unbearable.”

The gains by the National Front were somewhat less dramatic than predicted last week by the party itself after the first round of voting for mayors and City Council members, but exit polls suggested that the party would end up with about 10 mayoral seats in cities of more than 10,000. According to the preliminary official results from the Interior Ministry, at least two of those victories were in sizable municipalities: Béziers, in the south, and Fréjus, not far from Marseille, with populations of 70,000 and 52,000.

The ministry also said that nationwide the National Front had elected 934 local council members. It had fewer than 500 previously, so this was a substantial increase and allows it to have a presence in a number of localities even where it does not have mayors.

Marine Le Pen, the party’s leader, gave a resolute speech in which she reasserted that “the National Front has been born as an autonomous political force.”