He is said to have acted alone and police are not looking for other attackers, an official said.
The counterterrorism prosecutor’s office said an investigation had been opened into a terrorist attack.
In a message on Twitter, the Prime Minister said: “I am dismayed to hear this morning the news from Nice of a barbaric attack on the Notre-Dame basilica.
“Our hearts go out to the victims and their families, and the UK stands firmly with France against terror and intolerance.”
French media images showed the neighborhood locked down and surrounded by police and emergency vehicles. The killings took place less than half a mile from the site where another attacker drove a truck into a crowd on July 14, 2016, killing dozens of people.
Sounds of explosions could be heard when sappers detonated suspicious objects.
The mayor of Nice, Christian Estrosi, said the attacker shouted “Allahu akbar! “On several occasions when the police apprehended him and that” the meaning of his gesture left no doubt. ”
Speaking to reporters, Mr Estrosi said two people were killed inside the church and in a tweet added that the church keeper was among those attacked in Notre Dame Basilica.
Home Secretary Priti Patel, speaking during a visit to Essex Police Headquarters, said: ‘It is absolutely terrible and we are devastated for the people of France with the news we hear so far. ‘now.
“It is clear that we need to find a lot more information and this is only the first steps and of course we will talk to our colleagues in France. I will speak to my counterpart later today.
“But at this particular stage, all our thoughts are with the French people and obviously those who lost their lives today as well.
“And we are ready to provide all the support the French government needs at this really crucial time.”
Meanwhile, Foreign Minister Dominic Raab said: “The UK stands alongside France today in sadness, shock and solidarity over the horrific events in Nice.
“Our hearts go out to the victims and their families and we offer all our support to the French in pursuing those responsible for this appalling attack.
The exact motive for the attack was not clear, but comes as France is on alert for extremist Islamic acts amid tensions over two other recent attacks in France with links to cartoons of the Prophet Muhammad.
Less than two weeks ago, an attacker beheaded a French college professor who was showing caricatures of the Prophet Muhammad for a course on free speech. These cartoons were published by Charlie Hebdo and cited by the men who shot down the newspaper’s editorial meeting in 2015.
In September, a man who had applied for asylum in France attacked passers-by in front of the former Charlie Hebdo offices with a butcher’s knife.