France's governing Socialists never expected to do well in local elections, and their strategy worked as planned - their conservative rivals took first place.
Before the first round of elections for 2,000 local councils, the Socialists urged people to vote.
They hoped that high turnout would blunt the rise of Marine Le Pen's far right National Front, even if it meant Nicolas Sarkozy's conservative UMP would be the victor.
Initial projections from polling agencies gave the UMP party 31% of the vote compared with 24.5% for the National Front and 19.7% for the Socialists and their allies.
Turnout was 51%, compared with about 45% in similar elections in 2011.
With little air of a man in third place, Prime Minister Manuel Valls was the first to praise the far right party's defeat.
"This evening, the extreme right, even it is too high, is not at the forefront of French politics," he said. "When we mobilise the French, it works."
Ms Le Pen was not on the ballot papers herself, but her National Front is trying to build a grassroots army of local officials to buttress her presidential ambitions in 2017.
France's council elections are in two rounds, so victory yesterday determines which candidates can contest a second vote next Sunday.
The Socialists, which currently control the majority of the councils, are deeply unpopular after the government's failure to turn around France's economy.
Both they and the UMP are torn by infighting, leaving the National Front something of an open field for the first round.
But both the Socialists and UMP, normally rivals, have issued dire warnings about France's future under a resurgent National Front, which is opposed to immigration, the perceived "Islamisation" of France, and the European Union.
Ms Le Pen has exploited disillusionment with a stagnant economy and transformed the party from a pariah under her father, party co-founder Jean-Marie Le Pen, into one of France's most popular political forces.
Jockeying ahead of the second round started moments after the first-round results came in.
Mr Valls essentially called for voters to choose anyone running against a National Front candidate.
Mr Sarkozy, who like Ms Le Pen is eyeing the 2017 presidential race for a comeback, told supporters to abstain in the second round if a UMP candidate was not running.
And Ms Le Pen demanded Mr Valls' resignation for "trying to lead a campaign against the people, a filthy and violent campaign that stigmatised millions of French voters".
One outcome is certain - half of those elected will be women.
Instead of voting for individual candidates, the ballots contain tickets - one man, one woman - in order to overcome years of failed efforts to get more women into government. Currently, only 16% of council members are women.