The CCTV monitor was showing a live feed of gunmen in the hospital lobby. From the safety of another floor, Jan Yamit, a 23-year-old health worker, watched in horror as the militants shot a police officer and then a security guard before storming into the building.

The Philippines in flames: citizens flee as Isis flag flies over Marawi – in pictures

Read more

“I can’t explain what I was feeling. I was nervous. I am pissed by those kinds of people. They kill defenceless people,” he said of the attack in Marawi, a city on the southern Philippine island of Mindanao.

He and his brother, who worked as a lift operator in the building, sneaked from one room to another. Eventually, they found a wooden plank and made a bridge from the third floor to a neighbouring building.

“Those who were killed were Christians,” he said.

The attack on Marawi, a mainly Muslim city of 200,000 people, by the Islamic State-linked Maute group this week has led to a fierce three-day battle, with the army deploying attack helicopters and special forces.

At least 46 people – 15 members of the security forces and 31 militants – have been killed. On Friday, the Maute held its positions on bridges and remained hidden in buildings, despite heavy overnight artillery and airstrikes.

The Philippine president, Rodrigo Duterte, who cut short a foreign visit to Russia, has imposed martial law in Mindanao and promised bloodshed. “If there’s an open defiance, you will die,” he said on Wednesday. “And if it means many people dying, so be it.”

The clashes erupted after the military launched a botched raid on Tuesday to capture Isnilon Hapilon, a senior leader of Abu Sayyaf, a longstanding jihadi faction known for its involvement in piracy and kidnappings, and for beheading hostages. The military said he had joined the Maute, another Isis-linked insurgent group.

Within hours, the Maute had retaliated, taking over the hospital. The militants set light to a school and a church, and released about 100 prisoners from a jail.

Filipino villagers fleeing with their belongings as fighting between Maute militants and government forces continued in Marawi. Photograph: Merlyn T. Manos/EPA

In a sign that the long-standing problem of militancy in the south could be expanding, the solicitor general, Jose Calida, said foreigners were fighting alongside the gunmen in Marawi, including Indonesians and Malaysians. Calida called the violence an “invasion by foreign terrorists, who heeded the call of Isis to go to the Philippines if they find difficulty in going to Iraq and Syria”.

Aerial bombardments and street battles have forced thousands to flee, blocking roads for miles outside Marawi. Convoys of evacuees escorted by soldiers have flooded into nearby Iligan City.

Hamida Disangcupan, 51, said she ran into the street carrying bags of belongings after clashes erupted near her home on Thursday.

“We heard Isis had been here for several days. Soldiers came to tell us to evacuate. But where can we go?” she said, adding that she had been able to take temporary shelter in her sister’s house but would have to find more permanent accommodation.

Duterte arrived in nearby Iligan City on Friday to meet troops. The Maute have also been blamed for a failed bombing near the US embassy in Manila in November.

Analysts believe Isis militants are pushing to establish a base in south-east Asia, targeting the significant Muslim population on the island of Mindanao because of poverty and widespread distrust of the central government there. Several rebel groups espousing various causes operate here.

Lt Col Jo-Ar Herrera, the assigned military spokesman for Marawi, said soldiers were bogged down in the urban terrain, familiar to the Maute gunmen who are believed to have grown up in the area. The militants are also heavily armed, he said.

“The government must put an end to this,” he said. “I cannot gamble with Isis because they are everywhere and you know what is happening or you must be very aware of what is happening in the Middle East.”