UPDATE 5-France's far-right score local gains as voters punish Hollande
* Hollande allies trail conservatives, exit polls show
* FN wins Socialist bastion, leads in Avignon, Perpignan
* Second round run-offs due next Sunday (Releads with new quotes and details throughout)
By Dominique Vidalon
PARIS, March 23 (Reuters) - France's anti-immigrant National Front (FN) scored gains in first-round town hall elections on Sunday and took control of a former Socialist bastion as voters punished President Francois Hollande and his left-wing allies.
The elections in thousands of constituencies across France were the first nationwide voter test for Hollande, who came to power in May 2012 and has seen his popularity slump to record lows for failing to rein in unemployment.
A second round of voting is due next Sunday but FN leader Marine Le Pen, who has softened the party's image since taking over from her father Jean-Marie Le Pen in 2011, said advances made in the first round already marked a major breakthrough.
"The National Front has arrived as a major independent force - a political force both at the national and local level," Le Pen, who scored 18 percent in the 2012 presidential election, told TF1 television.
An exit poll by pollster BVA put Hollande's Socialists and their left-wing allies at 43 percent of the vote, trailing opposition conservatives whose 48 percent put them on track to reverse Socialist gains made in the 2008 municipal elections.
The FN scored seven percent of the vote, BVA estimated, a high national tally given that it only fielded candidates in 596 out of some 36,000 municipalities across France.
Its candidate Steeve Briois was declared winner with an outright majority of votes in the northern town of Henin-Beaumont, a former coalmining centre with 125,000 inhabitants that has long been in Socialist hands.
Exit polls put it ahead in the eastern town of Forbach in France's former industrial heartland. In the south, it was in the lead in Avignon, Perpignan, Beziers and Frejus and vying for second place in Marseille behind the conservative incumbent.
There was some solace for the Socialists as a TNS Sofres exit poll showed their candidate for Paris mayor, Anne Hidalgo, well ahead of her conservative rival Nathalie Kosciusko-Morizet.
Other polls gave Kosciusko-Morizet a better showing, but the mayor is chosen by the city council and analysts say the power balance there favours the Socialists.
"ALL AGAINST THE FN"
Pollsters have identified half a dozen towns that could see FN rule after next Sunday's run-offs, giving it the chance to show it can be trusted with power after attempts to run four towns in the late 1990s revealed its lack of competence.
With official figures expected to show turnout at record lows around 65 percent of voters, Prime Minister Jean-Marc Ayrault made a television appeal for "all democratic forces" to close ranks against FN candidates next week.
"Wherever the FN is in a position to win the second round, all who support democracy and the Republic have a duty to prevent them," Ayrault said, calling on voters to turn out in greater numbers than for the first round.
Heavy losses for Hollande's party could trigger a re-shuffle of his cabinet and encourage backbench attacks on a raft of new pro-business policies on which Hollande has called a vote of confidence in coming weeks.
However the final outcome will depend in some cases on highly unpredictable three-way races between the Socialists, the UMP and the National Front.
While Ayrault called for Socialist and UMP voters to back whichever of the major parties' candidates is best placed to ensure the FN does not win control of a town, the UMP is seen declining such a pact.
Le Pen has sanctioned or ejected members found to have made racist comments. While sceptics say much of the party's grass roots remains racist, analysts say the strategy has made it more acceptable to many potential voters.
"The National Front is much less repulsive than it has been in recent years," said Jean-Daniel Levy, an analyst with pollster Harris Interactive. "Voters are not looking for the most competent candidate, but the one who shares their feelings about the state of French society."
Polls also show the FN emerging as the leading French party in European Parliament elections in May. (Additional reporting and writing by Mark John; Editing by Tom Heneghan)