European leaders express relief following Macron victory

Nationalist Marine Le Pen ran on an anti-European Union platform.

"France -- a friend, neighbor and strategic partner of Spain -- will actively contribute to the advancement and reinforcement of the European Union in a key moment of its history," wrote Rajoy in a congratulatory message to Macron.

The German leader "praised [Macron's] stance for a united and open European Union during the campaign" and "[looks] forward to working together with the new president on the basis of trust in the spirit of the traditional German-French friendship."

Germany's Foreign Minister Sigmar Gabriel warned, however, that Macron must take action to boost the French economy to prevent Le Pen from building on her party's progress, saying Macron "must succeed, if he fails, in five years Mrs. Le Pen will be president and the European project will go to the dogs."

In a strongly worded tweet, Donald Tusk, the president of the European Council -- who has previously warned about the threat that changing political sentiments pose to the European Union -- congratulated Macron as well as the French people for choosing "Liberty, Equality and Fraternity over tyranny of fake news."

ABC News' Benjamin Gittleson and Joshua Hoyos and The Associated Press contributed to this report.