BERLIN (Reuters) - German Chancellor Olaf Scholz said on Monday he was "relieved" that the eurosceptic far right failed to win a snap election in top ally France, noting Berlin should be able to keep working with Paris to motor the European Union.

Marine Le Pen's National Rally (RN) had been favourite to top the polls. Instead the election threw up a hung parliament, with a leftist alliance unexpectedly taking the top spot but no group winning a majority, heralding tricky negotiations to form a government.

Germany and France, the two top economies in the European Union, have traditionally powered decision-making together in the unwieldy bloc of 27 member states.

"It would have been a major challenge if the French president had had to enter into a coalition with a right-wing populist party," Scholz, a Social Democrat, told reporters.

"This has now been averted and we now hope that the president, but also the elected representatives, will succeed in constructively forming a government."

As the largest EU country by population and economy, Germany had a greater interest in the success of the bloc than any other country, which was only possible through cooperation with France, Scholz said.

"This result gives us the basis to keep pursuing this task," he said. "It won't be easy, but it's worth the effort."

LOOKING ELSEWHERE FOR ALLIES

Relations between the EU's two biggest powers became strained after Scholz took office in late 2021 amid policy differences and a lack of chemistry between the German leader and his French counterpart Emmanuel Macron.

Domestic challenges - infighting in Scholz's three-way coalition and weak voter support for Macron - also hampered cooperation, slowing EU decision-making, although this has picked up over the past year amid shows of unity.

Scholz said on Monday he was pleased about the results not just because of the "important Franco-German friendship", but "on a personal level, given the good personal relationship I have with the French President."

German government officials had previously expressed surprise at Macron's decision to hold a snap election at a time of major challenges to the EU from trade tensions with China, Russia's invasion of Ukraine and the possible re-election of former U.S. President Donald Trump.

German Minister of State for Europe, Anna Luehrmann, told Reuters it was positive that pro-European forces had a majority in the French parliament.

Still, she said partnerships with other countries such as Poland and Britain were growing in importance after elections there yielded more like-minded governments.

Germany and Poland last week held government consultations together for the first time in six years and Luehrmann said Berlin should quickly seek to identify concrete areas of closer cooperation, especially on security and climate protection.

(Reporting by Sarah Marsh and Andreas Rinke; Editing by Matthias Williams and Christina Fincher)

By Sarah Marsh and Andreas Rinke