France's incumbent leader Emmanuel Macron and far-right challenger Marine Le Pen are heading for a 24 April presidential election runoff, projections showed after first round voting.
"Make no mistake, nothing is decided," he told cheering supporters.
He is heading for a convincing first-round victory, but opinion polls suggest the run-off could be much closer.
Le Pen called on every non-Macron voter to join her and "put France back in order".
With 96 percent of results counted, Emmanuel Macron had 27.42 percent of the vote, Marine Le Pen 24.03 percent and Jean-Luc Mélenchon 21.57 percent.
Veteran far-left candidate Jean-Luc Mélenchon polled even better than five years ago and now has the unlikely role of kingmaker.
"You must not give a single vote to Marine Le Pen," he warned his supporters, but unlike other candidates, he pointedly did not back the president instead.
With more than a fifth of the vote, Mélenchon voters could decide the election, and yet many of them may just sit the second round out.
Two old parties fail
Twelve candidates were in the running, but these were the only three who polled more than 10 percent. Many voters appeared to embrace the idea of tactical or "useful" voting, deciding that the other nine candidates had no hope of making the run-off.
Several of the nine had little chance anyway, but the 2022 presidential election will be partly remembered for the disaster that befell the two old parties that used to run France, the Republicans and Socialists. They sank almost without trace, with Socialist Anne Hidalgo falling below 2 percent.
It was only a few months ago that Valérie Pécresse was still in the race for the right-wing Republicans. She performed so badly her party was fighting to scrape the 5 percent needed to claim its election costs.
The battle for votes now starts in earnest. Marine Le Pen can count on supporters of Eric Zemmour, whose more hardline nationalism gave him fourth place and 7 percent. Nationalist Nicolas Dupont-Aignan has also backed her.
Most of the other candidates on the left have backed Macron, as did Valérie Pécresse, but one-time Socialist candidate Ségolène Royal said the president now had to "earn" victory.
Ifop pollster François Dabi said his company's 51 percent-49 percent estimate was the closest they had ever predicted. A BFMTV poll put the gap at 52 percent-48 percent and an Ipsos poll suggested it was slightly wider.
Addressing his supporters, Macron looked a relieved man and he promised to work harder than in the first part of the campaign. He only started campaigning eight days before, his mind more focused on Russia's war in Ukraine.
"When the extreme right in all its forms represents so much of our country," he said, "we cannot feel that things are going well."
He addressed Le Pen voters too: "I want to convince them in the next few days that our project answers solidly to their fears and challenges of our time."
Le Pen said there was a fundamental choice on 24 April of two opposite views: "Either division and disorder, or a union of the French people around guaranteed social justice."
One in four young voters backed the president, although more than one in three 18-24 year-olds opted for Jean-Luc Mélenchon, according to Elabe pollsters.
Marine Le Pen performed best among 35-64 year-olds, while the president was favoured by over-65s.
- BBC