NICE, FRANCE -- A young Tunisian man armed with a knife and carrying a copy of the Qur'an attacked worshippers in a French church and killed three Thursday, prompting the government to raise its security alert to the maximum level hours before a nationwide coronavirus lockdown.

The attack in Mediterranean city of Nice was the third in less than two months that French authorities have attributed to Muslim extremists, including the beheading of a teacher who had shown caricatures of the Prophet Muhammad in class after the images were re-published by a satirical newspaper targeted in a 2015 attack.

Thursday's attacker was seriously wounded by police and hospitalized in life-threatening condition after the killings at the Notre Dame Basilica. The imposing edifice is located half a mile (less than a kilometre) from the site where another attacker plowed a truck into a crowd on France's national day in 2016, killing dozens.

President Emmanuel Macron said he would immediately increase the number of soldiers deployed to protect schools and religious sites from around 3,000 to 7,000.

France's anti-terrorism prosecutor said the suspect is a Tunisian born in 1999 who reached the Italian island of Lampedusa, a key landing point for migrants crossing in boats from North Africa, on Sept. 20 and travelled to Paris on Oct. 9. Prosecutor Jean-Francois Ricard did not specify when he arrived in Nice.

The prosecutor said the attacker was not on the radar of intelligence agencies as a potential threat.

Video cameras recorded the man entering the Nice train station at 6:47 a.m., where he changed his shoes and turned his coat inside out before heading for the church, some 400 metres (yards) away, just before 8:30 a.m.

Ricard said the attacker was carrying a copy of Islam's holy book and two telephones. A knife with a 17-centimetre blade used in the attack was found near him along with a bag containing another two knives that were not used in the attack.

He had spent some 30 minutes inside the church before police arrived via a side entrance and "after advancing down a corridor they came face-to-face with (the attacker) whom they neutralized," Ricard said.

Witnesses heard the man crying "Allahu Akbar" as he advanced on police. Police initially used an electric gun then fired their service revolvers. Ricard said 14 bullet casings were found on the ground.

Ricard detailed a gruesome scene inside the church where two of the victims died. A 60-year-old woman suffered "a very deep throat slitting, like a decapitation," he said, and a 55-year-old man also suffered deep, fatal throat cuts. The third victim, a 44-year-old woman, managed to flee the church alive but died at a nearby restaurant.

.The three were killed "only because they were in the church at that moment," Ricard told reporters. He said investigators are looking for potential complicity in the "complex" probe.

An investigation was opened for murder and attempted murder in connection with a terrorist enterprise, a common term for such crimes.

The attack in Nice came amid a fierce debate in France and beyond over the re-publication of the Muhammad caricatures by satirical newspaper Charlie Hebdo.

The French consulate in the Saudi city of Jiddah was also targeted Thursday, a man claiming allegiance to an anti-immigrant group was shot and killed by police in the southern French city of Avignon, and scattered confrontations were reported elsewhere, but it is unclear whether they were linked to the attack in Nice.

France's national police chief had already ordered increased security at churches and mosques earlier this week, but no police appeared to be guarding the Nice church when it was attacked, and Associated Press reporters saw no visible security forces at multiple prominent religious sites in Paris on Thursday. French churches have been ferociously attacked by extremists in recent years, and Thursday's killings come ahead of the Roman Catholic All Saints' holiday.

"He cried `Allah Akbar!' over and over, even after he was injured," said Nice Mayor Christian Estrosi. "The meaning of his gesture left no doubt."

It was the third attack since Charlie Hebdo republished the caricatures in September as the trial opened for the 2015 attacks at the paper's offices and a kosher supermarket. The gunmen in that attack claimed allegiance to the Islamic State group and al-Qaida, which both recently called anew for strikes against France.

A verdict is planned for Nov. 13, the fifth anniversary of another series of deadly Islamic State attacks in Paris.

The recent attacks come amid renewed outcry over depictions of Islam's most revered prophet -- whose birthday was marked in several countries Thursday -- and the French government's fierce defence of the right to publish and show them. Muslims have held protests in several countries and called for a boycott of French goods. Dozens of Pakistani students rallied in the capital Thursday to denounce Macron.

"With the attack against Samual Paty, it was freedom of speech that was targeted," Prime Minister Jean Castex told lawmakers Thursday, referring to the teacher who was beheaded after showing his class caricatures of the prophet during a civics lesson. "With this attack in Nice, it is freedom of religion."

Earlier, the lower house of parliament suspended a debate on France's new virus restrictions and held a moment of silence for the victims. Castex rushed from the hall to a crisis centre overseeing the aftermath of the Nice attack and later returned to announce the alert level increase. Macron left for Nice almost immediately.

"Very clearly, it is France which is under attack," Macron said as he stood before the church. He added that all of France offered its support to Catholics "so that their religion can be exercised freely in our country. So that every religion can be practiced. "

In Avignon on Thursday morning, a man with a firearm was shot and killed by police after he refused to drop his weapon and a warning shot failed to stop him, a police official said. And a Saudi state-run news agency said a man stabbed a guard at the French consulate in Jiddah, wounding the guard before he was arrested.

While many groups and nations have been angered or frustrated by France's position on the cartoons, several issued their condolences Thursday, as did France's traditional allies.

The French Council of the Muslim Faith condemned the Nice attack and called on French Muslims to refrain from festivities marking the birth of Muhammad "as a sign of mourning and in solidarity with the families of victims and the Catholics of France."

Turkey's Foreign Ministry strongly condemned the attack. "We stand in solidarity with the people of France against terror and violence," the statement said.

Relations between Turkey and France hit a new low after Turkey's president accused Macron of Islamophobia over the caricatures and questioned his mental health, prompting Paris to recall its ambassador to Turkey for consultations.

The attack in Nice came less than two weeks after Paty, the teacher, was beheaded. In September, a man who had sought asylum in France attacked bystanders outside Charlie Hebdo's former offices with a butcher knife.

French Jewish and Catholic sites have also frequently been targeted, including the killing of the Rev. Jaqcues Hamel, who had his throat slit while celebrating Mass in his Normandy church by Islamic militants and a plot to bomb Paris' Notre Dame cathedral. Those attacks were claimed by the Islamic State group, which also is believed to have recruited a man now on trial for an unsuccessful plot to attack a church.

------

Hinnant reported from Paris. Associated Press writers Angela Charlton and Thomas Adamson and Elaine Ganley in Paris and Zeynep Bilginsoy in Istanbul contributed to this report.