The ruling French Socialist party has narrowly beaten the far-right National Front at a by-election seen as a test for President Francois Hollande.
The poll was billed as a reflection of the country's political climate after last month's terror attacks in Paris.
Mr Hollande's approval ratings improved significantly as a result of his handling of the crisis.
However, the Socialist candidate at the by-election in Doubs, eastern France, won by less than three points.
Frederic Barbier, who won 51.4% of the vote, said his victory over Sophie Montel had been helped in part by the "perfect" response of France's leaders to the terror attacks.
However. the narrow margin of his triumph led Ms Montel to say the National Front was the election's "big winner".
The poll was triggered by the resignation of the sitting Socialist MP.
Reflecting its importance in the minds of French leaders, both the country's prime minister and interior minister travelled to the constituency to help campaign for Mr Barbier.
In his victory speech, Mr Barbier said the win could be a "turning point" for Mr Hollande.
According to one opinion poll, the French president saw his popularity rating double to 40% in the days after the terror attacks which began on 7 January with the massacre of staff at the office of Charlie Hebdo satirical magazine in the French capital.
However another survey published in a national newspaper on Sunday suggested two-thirds of French people still thought Mr Hollande a "bad president".