Backed by tanks and helicopters, Philippine government forces launched “precision attacks” Thursday to clear militants linked to the Islamic State group from a city that has been under siege since a failed raid to capture a militant on the US list of most-wanted terrorists.

Militants have torn through the streets of Marawi since Tuesday night, torching buildings, taking a priest and his worshippers hostage and sealing off much of the city. The violence forced thousands to flee and raised fears of growing extremism in the country.

Around 20 people have died in the fighting, including 13 militants and five soldiers, said Lt. Col. Jo-ar Herrera, a military spokesman. President Rodrigo Duterte said a local police chief was stopped at a militant checkpoint and beheaded.

It was not immediately clear whether civilians were among the dead.

“At night we can hear the gunfire,” said Mohammad Usman, who watched from his home just outside Marawi as thousands of residents streamed out of the city. “I’m just praying that the bullets will not find their way to my house and hit us. I hope that the bombs will not land nearby and harm us.”

Mr. Duterte imposed 60 days of martial law Tuesday on the island of Mindanao, which encompasses the southern third of the nation and is home to 22 million people. Marawi has a population of around 200,000.

Duterte warned he may expand martial law nationwide, an unnerving development for many in the Philippines who lived through the rule of Ferdinand Marcos. Marcos declared martial law in 1972 and used it to maintain his grip on power for more than a decade.

The man at the center of the Marawi violence is Isnilon Hapilon, an Arabic-speaking Islamic preacher known for his expertise in commando assaults. He is at the nexus of several militant groups that are trying to merge into a more powerful force.

Mr. Hapilon, who is a commander of the Abu Sayyaf militant group, pledged allegiance to the Islamic State group in 2014. He also heads an alliance that includes at least 10 smaller militant groups, including the Maute, which have a heavy presence in Marawi and were instrumental in fighting off government forces in this week’s battles.

All these groups are inspired by the Islamic State group, but so far there is no sign of significant, material ties.

“We have not seen any concrete evidence of material support from IS,” military spokesman Brig. Gen. Restituto Padilla said Thursday. But he added that the smaller groups “are working to really get that recognition and funds, of course.”

Washington has offered a $5 million reward for information leading to Hapilon’s capture, but he has proved elusive. The Philippines launched an airstrike that wounded him in January, but he got away.

The Army raided what it believed to be his hideout on Tuesday night in Marawi, but the operation quickly went wrong. Militants called in reinforcements and were able to overpower government forces. Once again, Hapilon escaped.

“Based on reports, he is still in the city,” Herrara told reporters in Marawi on Thursday as gunfire crackled in the background.

Much of Marawi was still a no-go zone Thursday. Automatic gunfire and explosions could be heard clearly and plumes of black smoke rose from the direction of the city center. Air force helicopters swooped overhead.

“Attack helicopters fired rockets in a precision attack,” Mr. Herrera said. “We want to finish this problem as soon as possible.”

As authorities try to gain more control over the city, disturbing details have emerged.

Militants forced their way into the Marawi Cathedral and seized a Catholic priest, 10 worshippers and three church workers, according to the city’s bishop, Edwin de la Pena. The black flags of the Islamic State group were planted atop buildings and flown from commandeered vehicles, including a government ambulance and an armored car, said Mamintal Alonto Adiong Jr., vice governor of Lanao del Sur province, of which Marawi is the capital.

More than half of the population of Marawi has cleared out, Adiong said.

Get the Monitor Stories you care about delivered to your inbox. By signing up, you agree to our Privacy Policy

The problem of militancy in the south, the scene of decades-long Muslim separatist uprisings in the predominantly Catholic nation, is not new.

Duterte had repeatedly threatened to place the region under martial law, which allows him to use the armed forces to carry out arrests, searches and detentions more rapidly. But human rights groups and others fear that martial law powers could further embolden the president, who already has been accused of allowing extrajudicial killings of thousands of people in his crackdown on illegal drugs.