PARIS — An attacker armed with a knife killed three people inside a church Thursday in the Mediterranean city of Nice, prompting the government to raise its security alert status to the highest level and double the number of soldiers deployed in the country.

It was the third attack in two months in France that authorities have attributed to Muslim extremists, including the beheading of a teacher. It comes during a growing furor over caricatures of the Prophet Muhammad that were republished by the satirical newspaper Charlie Hebdo — renewing vociferous debate in France and the Muslim world over the depictions that Muslims consider offensive but are protected by French free speech laws.

Other confrontations and attacks were reported Thursday in the southern French city of Avignon and in the Saudi city of Jiddah, but it was not immediately clear if they were linked to the attack in Nice.

French President Emmanuel Macron said he would immediately increase the number of soldiers deployed to protect schools and religious sites from around 3,000 currently to 7,000. 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, who said a woman and a man died inside the church, while a second woman fled to a nearby bar but was mortally wounded. “The meaning of his gesture left no doubt.”

The assailant in Nice was wounded by police and hospitalized after the killings at the Notre Dame Basilica, about a half-mile from the site in 2016 where another attacker plowed a truck into a Bastille Day crowd, killing dozens of people.

Shots punctuated the air and witnesses screamed as police stationed at the grandiose doors to the church appeared to fire at the attacker inside, according to videos obtained by The Associated Press. Hours later, AP reporters at the scene saw emergency vehicles and police tape lining the wide Notre Dame Avenue leading toward the plaza in front of the basilica. For a time after the attack, sounds of explosions could be heard as sappers exploded suspicious objects.

France’s anti-terrorism prosecutor’s office opened an investigation into the attack, the third one since a trial opened in September for people linked to the 2015 attacks at Charlie Hebdo and a kosher supermarket by gunmen who claimed allegiance to the Islamic State group and al-Qaida. The trial is nearing its end, with a verdict planned for Nov. 13, the fifth anniversary of another series of deadly Islamic State attacks in Paris.

Thursday’s attacker was believed to be acting alone and police are not searching for other assailants, said two police officials, who were not authorized to be publicly named.

“With the attack against (teacher) Samual Paty, it was freedom of speech that was targeted. With this attack in Nice, it is freedom of religion,” Prime Minister Jean Castex told lawmakers Thursday.

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 center overseeing the aftermath of the Nice attack and later returned to announce the alert level increase. French President Emmanuel Macron, who has defended Charlie Hebdo’s right to publish the caricatures, arrived in Nice later in the day.

Muslims have held protests in several countries and called for a boycott of French goods in response to France’s stance on caricatures of Islam’s most revered prophet, whose birthday was marked in several countries Thursday. Soon before Thursday’s attack, supporters of religious political party Jamiat Ulema-e-Islam protested in Pakistan against Macron.

In Avignon on Thursday morning, an armed man was shot to death by police after he refused to drop his weapon and a flash-ball shot failed to stop him, one 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.

Islamic State extremists had issued a video on Wednesday renewing calls for attacks against France.

Many groups and nations, however, issued their condolences Thursday, standing firmly with France.

The French Council of the Muslim Faith condemned the Nice attack and called on French Muslims to refrain from festivities this week marking the birth of Muhammad “as a sign of mourning and in solidarity with the victims and their loved ones.”

Turkey’s Foreign Ministry strongly condemned the attack in Nice. “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 on Saturday 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 another assailant beheaded a French middle school teacher who showed the caricatures of the Prophet Muhammad for a class on free speech. Those caricatures were published by Charlie Hebdo and cited by the men who gunned down the newspaper’s editorial meeting in 2015.

In September, a man who had sought asylum in France attacked bystanders outside Charlie Hebdo’s former offices with a butcher knife.

French Roman Catholic sites have been ferociously and repeatedly targeted by extremists in recent years, 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 who plotted unsuccessfully to attack a church on the outskirts of Paris.

Nice’s 19th-century basilica Notre Dame de l’Assomption is the largest church in the city, but smaller and newer than the cathedral 1 mile away. The basilica’s twin neogothic towers, standing 70 yards high, are a landmark feature in the heart of the city.