The attack took place in a church, the Notre Dame Basilica, on Thursday. The victims include one woman who was "decapitated" inside the church, Mayor Christian Estrosi said.
Estrosi said the attacker was shot by police, but is still alive and has been taken into custody.
"I am on the scene with the police who arrested the attacker. Everything points to a terrorist attack," Estrosi said on Twitter Thursday morning.
"At this moment, we have, without any doubt, two dead inside the church, horribly," Estrosi said shortly afterwards during a press conference.
"It seems that, according to the first findings of the police, the woman who was inside the church has been decapitated. For the other victims, we cannot say anything at the moment," Estrosi told French news channel BFMTV.
France's Interior Minister Gérald Darmanin said he was chairing a crisis meeting at the ministry in response to the attack.
President Emmanuel Macron will travel to Nice after attending that meeting, the Élysée Palace said.
France's anti-terror prosecutor has taken on the investigation into the attack, a spokesperson for the prosecutor's office said.
The President of the European Parliament, David Sassoli, said he was deeply saddened by the incident.
"I am deeply shocked and saddened by the news of the horrific attack in Nice. This pain is felt by all of us in Europe," he said on Twitter.
"We have a duty to stand together against violence and those that seek to incite and spread hatred."