He will succeed fellow conservative Jacques Chirac, who was president for 12 years.
Sarkozy’s face flashed up on television screens after polling stations closed at 8pm (18:00 GMT), signalling his victory and setting off jubilant scenes among thousands of supporters who had gathered in central Paris.
But there were also skirmishes between leftist supporters and police in at least one city square and reports of sporadic violence in two suburbs near the capital.
At the Socialist headquarters there was gloom after the party crashed to its third consecutive presidential election defeat. It now faces the prospect of tough internal reforms to make itself more appealing to voters.
Call for unity
In a speech at the UMP headquarters, Sarkozy said: “To all those French who did not vote for me, I want to say, beyond political battles, beyond differences of opinion, for me there is only one France. I want to tell them that I will be president of all the French.”
European Union leaders congratulated Sarkozy, who promised to put France back into the driving seat of Europe after the country voted down the EU constitution in a 2005 referendum.
Said Sarkozy after his win: “I want to launch a call to our European partners, with whom our destiny is deeply linked, to tell them that I have been European all my life, that I believe deeply, that I believe sincerely, in European construction and that tonight France is back in Europe.
George Bush, the US president, also telephoned to offer his congratulations and said he expected good relations with Sarkozy, who has made a priority of repairing the damage to French-US relations caused by tensions over the Iraq war.
Sarkozy told the US “that France will always be by their side when they will need her”.
“But I want to tell them as well that friendship is accepting that one’s friends can act differently, and that a great nation like the United States has the duty to not obstruct the fight against global warming but on the contrary to head this struggle because what is at stake is the future of all humanity. France will make this struggle its first struggle.”
Although opinion polls regularly suggested Royal, who was seeking to become France’s first female head of state, was more likeable, voters seemed to see the uncompromising Sarkozy as a more competent leader with a more convincing economic programme.
Talking before her supporters, Royal said: “I hope the next president of the republic fulfils his role in the service of all French people … I will continue with you and near you…You can count on me to deepen the renovation of the left … that is the condition of our future victories.”
The president in France is elected for five years, is commander-in-chief of the armed forces, nominates the prime minister and is responsible for foreign and defence policies.