At least seven soldiers and police officers were killed in the Philippines city of Marawi where government forces carried out an operation to rescue dozens of hostages held by Islamic State-linked terrorists, according to the army.

Five soldiers and two policemen have been killed in sporadic clashes with militants since Tuesday, Col. Edgard Arevalo of the Armed Forces of the Philippines (AFP) Public Affairs Office announced late Wednesday.

The army managed to kill at least 13 gunmen of the IS-affiliated (Islamic State, formerly ISIS/ISIL) Maute group who had overrun the local clinic, taking hostages, and occupying Marawi’s City Hall.

Government forces managed to rescue 78 civilians from the Amai Pakpak Medical Center where the terrorists tried to use them as human shields as the army moved in, Western Mindanao Command chief, Lt. Gen. Carlito Galvez Jr., said according to the PhilStar daily.

The troops also secured 42 teachers who had taken refuge and got trapped at Dansalan College after the city was engulfed in violence.

Authorities provided no details of civilian injuries and casualties, but said at least 31 soldiers were wounded in the attempt to rescue the hostages and escort civilians to safety.

On Tuesday night, President Rodrigo Duterte placed the entire island of Mindanao under martial law for 60 days after battles between government troops and the Maute in Marawi escalated. Duterte was forced to cut short his trip to Russia to return home to tackle the terrorist insurgency.

“Anyone now holding a gun, confronting the government with violence, my orders are spare no one, let us solve the problems of Mindanao once and for all,” Duterte said Wednesday.

“If I think you should die, you will die. If you fight us, you will die. If there’s an open defiance, you will die, and if it means many people dying, so be it. That’s how it is,” he added.

Duterte also warned that he will not hesitate to declare martial law throughout the entire country if terrorism spills beyond Mindanao.

“Government may consider the covered areas of martial law, in the event that members of Maute group and other ISIS-affiliated terrorists seek sanctuary or expand their terrorist activities in the Visayas and Mindanao,” Duterte said.

“I will not allow the country to go to the dogs. As I said, the military has the primary role now of keeping the law and order situation and in all parts of the Republic of the Philippines,” the president said.

The Philippines leader also promised to resign if extremists prove him incapable of maintaining peace in his country.

“As president, if I cannot confront them, I will resign,” Duterte said. “If I am incompetent and incapable of keeping order in this country, let me step down and give the job to somebody else.”