By Luke Baker

PARIS (Reuters) - Marine Le Pen's far-right Rassemblement National rode a wave of nationalist sentiment to win the most votes in France's election to the European Parliament on Sunday, but the margin of victory over President Emmanuel Macron's party was narrow.

An Elabe exit poll showed Rassemblement National, formerly known as the National Front, securing 23.6% of the vote, a little over one percentage point ahead of Macron's La Republique En Marche list on 22.4%.

While the result is a defeat for Macron - who has put Europe at the heart of his presidency and personally invested time in the campaign - it was a far better performance than previous incumbents.

Former president Francois Hollande's party won just 14% of the vote in the last European election in 2014, coming third.

Le Pen and her lead candidate, Jordan Bardella, had sought to turn the election into a referendum on Macron's first two years in power, calling on supporters to show their repudiation of Macron's economic reforms and pro-European policies.

"The French people have sent a very clear message and a lesson in humility" to Macron, Bardella told supporters. "It’s him and his politics that have been rejected."

The result is a lift for Le Pen, who hopes to build a far-right alliance in Europe alongside Italy's deputy prime minister Matteo Salvini and other far-right parties who say EU nations have surrendered too much 'sovereignty' to Brussels.

But her support had fallen from the last EU vote, when her party won 24.8%. The EU ballot is often treated as a protest vote, which tends to hurt the party in power.

Macron, who formed his own movement to run for the French presidency in 2017, shattering the traditional center-right and center-left blocs, had never contested a European election before. He portrayed the vote as a battle between pro-EU "progressives" such as himself and anti-immigration nationalists such as Le Pen and Salvini.

Reacting to the results, an Elysee official called them "disappointing" but not punishing. Another said Macron would not deviate from his reformist agenda as a result.

But some analysts said the vote highlighted the scepticism at his pro-business economic agenda felt by a large chunk of voters and played out in the streets over the past six months during anti-government 'gilets jaunes' protests.

"He risks having even more limited room for maneuver in his reforms and getting locked into a head-to-head confrontation with the RN, which has established itself as the main opposition party, until the next presidential election," said Christopher Dembik, economist at Saxo Bank.

Others criticized the performance of Macron's campaign flagbearer, former Europe minister Nathalie Loiseau.

FAR-RIGHT RISES, AGAIN

An Elabe poll projected the RN would get 24 seats in the European parliament compared with 23 percent for Macron's party.

For Macron, the question will be whether his ambitions to lead in Europe will be dented by his second place in France.

He has opposed Germany's Manfred Weber from the center-right European People's Party group as the lead candidate to become European Commission president. Instead, he backs France's Michel Barnier, the EU's chief Brexit negotiator.

Macron aims to forge a centrist alliance with liberal, pro-European parties, a bloc currently known as ALDE but which may change its name. The leader of ALDE in the European Parliament, Guy Verhofstadt, said Macron would join forces with the group.

The group is expected to have around 100 seats in the 751-seat European Parliament, which would make it the third-strongest bloc and potentially a "kingmaker".

Because no single group will have a majority in the parliament, alliances will be necessary to secure the 376 seats needed to carry a vote on decisions such as the next Commission president. Macron has said he will aim to build an alliance with the center-left Socialists and Democrats, the Greens, and potentially center-right Christian Democrats.

(Additional reporting by Inti Landauro, Richard Lough and Michel Rose in Paris; Writing by Luke Baker; Editing by Richard Lough and Andrew Heavens)