ILIGAN CITY, Philippines -- Islamic State group-linked militants swept through a southern Philippine city, beheading a police chief, burning buildings, seizing a Catholic priest and his worshippers and raising the black flag of IS, authorities said Wednesday. President Rodrigo Duterte, who had declared martial law across the southern third of the nation, warned he may expand it nationwide.

At least 21 people have died in the fighting, officials said.

As details of the attack in Marawi city emerged, fears mounted that the largest Roman Catholic nation in Asia could be falling into a growing list of countries grappling with the spread of influence from the Islamic State group in Syria and Iraq.

The violence erupted Tuesday after the army raided the hideout of Isnilon Hapilon, a commander of the Abu Sayyaf militant group who has pledged allegiance to IS. He is on Washington's list of most-wanted terrorists with a $5 million reward for information leading to his capture.

The militants called for reinforcements and around 100 gunmen entered Marawi, a mostly Muslim city of 200,000 people on the southern island of Mindanao, Defence Secretary Delfin Lorenzana said.

"We are in a state of emergency," Duterte said Wednesday after he cut short a trip to Moscow and flew back to Manila. "I have a serious problem in Mindanao and the ISIS footprints are everywhere."

He declared martial rule for 60 days in the entire Mindanao region -- home to 22 million people -- and vowed to be "harsh."

"If I think that you should die, you will die," he said. "If you fight us, you will die. If there is open defiance, you will die. And if it means many people dying, so be it."

But he said he would not allow abuses and that law-abiding citizens had nothing to fear.

Duterte said a local police chief was stopped at a militant checkpoint and beheaded, and added that he may declare martial law nationwide if he believes the group has taken a foothold.

Marawi Bishop Edwin de la Pena said the militants forced their way into the Marawi Cathedral and seized a Catholic priest, 10 worshippers and three church workers.

The priest, Father Chito, and the others had no role in the conflict, said Archbishop Socrates Villegas, president of the Catholic Bishops Conference of the Philippines.

"He was not a combatant. He was not bearing arms. He was a threat to none," Villegas said of Chito. "His capture and that of his companions violates every norm of civilized conflict."

Villegas said the gunmen are demanding the government recall its forces.

Military spokesman Col. Edgard Arevalo said 13 militants had been killed, and that five soldiers had died and 31 others were wounded. Other officials said a security guard and two policemen were also killed, including the beheaded police chief.

Arevalo said troops had cleared militants from a hospital, the city hall and Mindanao State University. About 120 civilians were rescued from the hospital, the military said.

Thousands of people have fled the city, said Mary Jo Henry, an emergency response official. She quoted another official as saying Marawi was like "a ghost town."

Broadcaster ABS-CBN showed people crammed inside and on top of public vehicles leaving the area, and some walking on foot with their belongings as they passed through a security checkpoint manned by soldiers.

Martial law allows Duterte to use the armed forces to carry out arrests, searches and detentions more rapidly. He has repeatedly threatened to place the south, the scene of decades-long Muslim separatist uprisings, under martial law. But human rights groups have expressed fears that martial law powers could further embolden Duterte, whom they have accused of allowing extrajudicial killings of thousands of people in his crackdown on illegal drugs.

Hapilon, an Arabic-speaking Islamic preacher known for his expertise in commando assaults, pledged allegiance to the Islamic State group in 2014. He is a commander of the Abu Sayyaf militant group and was wounded by a military airstrike in January.

Troops sealed off major entry and exit points to prevent Hapilon from escaping, military chief of staff Gen. Eduardo Ano told The Associated Press late Tuesday.

"We will conduct house-to-house clearing and do everything to remove the threat there. We can do that easily," Ano said, but added it was more difficult in an urban setting because of the need to avoid civilian casualties.

He said the group erected Islamic State flags at several locations.

Duterte met late Tuesday with Russian President Vladimir Putin and said he is counting on Russia to supply weapons for the Philippines to fight terrorism.

"Of course, our country needs modern weapons, we had orders in the United States, but now the situation there is not very smooth and in order to fight the Islamic State, with their units and factions, we need modern weapons," he said, according to Russian state news agency Tass.

While pursuing peace talks with two large Muslim rebel groups in the south, Duterte has ordered the military to destroy smaller extremist groups which have tried to align with the Islamic State group.

At least one of those smaller groups, the Maute, was involved in the Marawi siege. It's one of less than a dozen new armed Muslim groups that have pledged allegiance to the Islamic State and formed a loose alliance, with Hapilon reportedly designated as the alliance's leader.

Political analyst Ramon Casiple said the Maute is a clan-based group with members in Marawi who came to Hapnilon's assistance, with some directly assisting in the fighting and others fanning out to different parts of the city, setting up checkpoints and burning some buildings and taking hostages from the cathedral.

"It is difficult to root out because they are from there," he said. "The Mautes are embedded in the population."

The group has been blamed for a bombing that killed 15 people in southern Davao city, Duterte's hometown, last September and a number of attacks on government forces in Lanao, although it has faced setbacks from a series of military offensives.

Last month, troops backed by airstrikes killed dozens of Maute militants and captured their jungle camp near Lanao del Sur's Piagapo town. Troops found homemade bombs, grenades, combat uniforms and passports of suspected Indonesian militants in the camp, the military said.

Cerojano reported from Manila