Socialist candidate Frederic Barbier won 51.43 per cent of the vote in last night’s second round run off in the low-income eastern Doubs region, not far ahead of National Front (FN) candidate Sophie Montel on 48.57 per cent.
Amid high unemployment and stagnant growth in France, Hollande's party had suffered a string of defeats in by-elections held since he became president in May 2012.
But Hollande’s handling of the terrorist attacks in Paris in January was widely-praised and led to a boost in his poll ratings while Prime Minister Manuel Valls also shot up in opinion polls for the same reason.
Martial Bourquin, a Socialist senator in Doubs, told reporters last night the duel between both candidates in the second round had been tough.
"It's an extremely close fight with a strong turnout and a strong FN score," he said.
Nicolas Sarkozy’s UMP party was knocked out in the first round of the election.
After a fractious party meeting on Tuesday, the UMP called on its supporters to abstain from voting for either candidate on Sunday.
Although the FN candidate didn’t win the seat, party leader Marine Le Pen said the score was still a major victory for the FN.
The party has gone from strength to strength since Marine Le Pen took over in 2011 and began a campaign to try to revamp the image of the party which was widely regarded as taboo when her father Jean-Marie Le Pen was at the helm.
The FN won control of 11 towns and more than 1,200 municipal seats nationwide in local elections last year - a huge success for a party which in the last local polls in 2008 had claimed only around 60 seats.