The far-right Front National (FN) scored a historic victory in elections to the French senate on Sunday, winning its first ever seats in the upper chamber as the ruling Socialists and their leftwing allies lost their majority to rightwing parties.

The shock victory of Stéphane Ravier from Marseilles and David Rachline from Fréjus confirmed the party’s political breakthrough under Marine Le Pen, who has brushed the poisonous legacy of her father Jean-Marie Le Pen under the carpet in an attempt to “de-demonise” the FN.

The two seats are both in the FN’s stronghold in southern France, and at 26 Rachline, the mayor of Fréjus, is the youngest French senator ever elected.

The result marks a third humiliating electoral defeat for the Socialist party, which has been punished by disillusioned voters while support for the FN has surged. Le Pen’s party won control of a dozen municipalities in elections last March, including the 7th district in Marseilles where Ravier was elected mayor.

It also came top in the European elections two months later, when it knocked the centre-right UMP into second place. One poll earlier this month said that Le Pen could theoretically beat the country’s president, François Hollande, in the second round of the next presidential election, scheduled for 2017.

Referring to the presidency after his election to the senate, Ravier said: “There’s just one more door to open, the Elysée. In 2017 we’ll have Marine Le Pen to do it.”

Sunday’s complex vote was for half of the 348 seats in the senate by an electoral college of 87,000 voters made up of city councillors and local officials. A first round of voting which concluded around midday provided a foretaste of the final shock result, with the Socialists losing seven seats, including in Hollande’s own constituency of La Correze. “It’s Berezina,” one leading Socialist said, referring to Napoleon’s defeat while retreating from Russia.

With Hollande’s popularity at an unprecedented low of 13% and the government hit by budget woes, record joblessness and zero growth, his party had expected to lose the senate majority it has held with the Communists and Greens since 2011.

Le Pen hailed her party’s success as a “great victory, an absolutely historic victory” which she said would represent a “breath of fresh air in a rather sleepy chamber”.

“With every day that passes, our ideas are making progress,” she told BFMTV, predicting further gains for the FN in the forthcoming territorial and regional elections.

The result is also a much-needed shot in the arm for the UMP of the former president Nicolas Sarkozy, who is bidding to return to head the party. Sarkozy returned to the political arena last week, and is clearly positioning himself for another run at the presidency after Hollande defeated him in 2012.

With the final senate results still awaited, the Socialist leader, Jean-Christophe Cambadélis, played down the scale of his party’s defeat, saying it had feared greater gains by the opposition right-wing parties.

The Socialist leader of the senate, Didier Guillaume, predicted that the right would not have a stable majority, saying that the UMP would need to rely on centrist allies. The government spokesman Stéphane Le Foll stressed that whatever the outcome, the prime minister, Manuel Valls, would not be deflected from his reform plans.