MARAWI CITY, Philippines (Reuters) - At the beginning of the battle that has raged for the past 12 days in Marawi City at the southern end of the Philippines, dozens of Islamist militants stormed its prison, overwhelming the guards.

FILE PHOTO: Soldiers stand guard along the main street of Mapandi village as government troops continue their assault on insurgents from the Maute group, who have taken over large parts of Marawi City, Philippines June 2, 2017. REUTERS/Romeo Ranoco

“They said ‘surrender the Christians’,” said Faridah P. Ali, an assistant director of the regional prison authority. “We only had one Christian staff member so we put him with the inmates so he wouldn’t be noticed,” he said.

Fighters from the Maute group, which has pledged allegiance to Islamic State (IS), menaced the guards and shouted at prisoners: but no one gave up the Christian man. “When they freed the inmates, he got free,” said Ali.

It was a brief moment of cheer, but over the next few hours the militants took control of most of the city, attacked the police station and stole weapons and ammunition, and set up roadblocks and positioned snipers on buildings at key approaches. The assault has already led to the death of almost 180 people and the vast majority of Marawi’s population of about 200,000 has fled.

For a graphic about the battle:(tmsnrt.rs/2rhRPEa)

The seizing of the city by Maute and its allies on the island of Mindanao is the biggest warning yet that the Islamic State is building a base in Southeast Asia and bringing the brutal tactics seen in Iraq and Syria in recent years to the region.

Defense and other government officials from within the region told Reuters evidence is mounting that this was a sophisticated plot to bring forces from different groups who support the Islamic State together to take control of Marawi.

The presence of foreigners - intelligence sources say the fighters have included militants from as far away as Saudi Arabia, Pakistan, Chechnya and Morocco - alongside locals in Marawi, has particularly alarmed security officials.

For some time, governments in Southeast Asia have been worried about what happens when battle-hardened Islamic State fighters from their countries return home as the group loses ground in the Middle East, and now they have added concerns about the region becoming a magnet for foreign jihadis.

“If we do nothing, they get a foothold in this region,” said Hishammuddin Hussein, the defence minister of neighboring Malaysia.

Defense and military officials in the Philippines said that all four of the country’s pro-Islamic State groups sent fighters to Marawi with the intention of establishing the city as a Southeast Asian ‘wilayat’ – or governorate - for the radical group.

Mindanao - roiled for decades by Islamic separatists, communist rebels, and warlords – was fertile ground for Islamic State’s ideology to take root. This is the one region in this largely Catholic country to have a significant Muslim minority and Marawi itself is predominantly Muslim.

It is difficult for governments to prevent militants from getting to Mindanao from countries like Malaysia and Indonesia through waters that have often been lawless and plagued by pirates.

The Combating Terrorism Center, a West Point, New York-based think tank, said in a report this week that Islamic State is leveraging militant groups in Southeast Asia to solidify and expand its presence in the region. The key will be how well it manages relations with the region’s jihadi old guard, CTC said.

COMMANDER FIRED

The Maute group’s attack is the biggest challenge faced by Philippines President Rodrigo Duterte since coming to power last June. He has declared martial law in Mindanao, which is his political base.

His defense forces were caught off guard by the assault and have had difficulty in regaining control of the city - on Saturday they were still struggling to wipe out pockets of resistance.

On Monday, Brigadier-General Nixon Fortes, the commander of the army brigade in Marawi, was sacked.

An army spokesman said this was unrelated to the battle. But a military source, speaking on condition of anonymity, told Reuters on Friday that Fortes was dismissed because not all his forces were in the city when the rebels began their rampage, even though military intelligence had indicated that Islamist militants were amassing there.

The assault came just months after security forces attacked the mountain lair of Isnilon Hapilon, a long-time leader of Abu Sayyaf, or “Father of the Sword”, a notorious Islamist militant group known for kidnapping.

He swore allegiance to Islamic State in 2014, and quickly got other groups to join him. Most important among them was the Maute group, run by brothers Omar and Abdullah Maute from a well-known family in Marawi.

In a video that surfaced last June, a Syria-based leader of the group urged followers in the region to join Hapilon if they could not travel to the Middle East. Hapilon was named IS leader in Southeast Asia last year.

The Philippines military said Hapilon was likely wounded in the raids but managed to escape to Marawi, where he joined up with the Maute group.

According to a statement on a social media group used by Maute fighters, the group wants to cleanse Marawi of Christians, Shi’ite Muslims, and polytheists – who believe in more than one God. It also wants to ban betting, karaoke and so-called “relationship dating.”

MOUNTAIN LAIRS

Some officials said Philippines security forces became complacent about the threat from IS after the January raids.

“We did not notice they have slipped into Marawi because we are focusing on their mountain lairs,” Philippines Defence Secretary Delfin Lorenzana told reporters.

Over the past few months, Philippine and Indonesian intelligence sources said, Hapilon’s forces were swelled by foreign fighters and new recruits within Marawi. Many of the outsiders came to Marawi using the cover of an Islamic prayer festival in the city last month, said Philippines military spokesman Lt. Col. Jo-Ar Herrera.

Lorenzana said that Hapilon brought 50-100 fighters to join Maute’s 250-300 men, while two other groups, the Bangsamoro Islamic Freedom Fighters and the Ansar Al-Khilafah Philippines, together brought at least 40 militants with them.

On May 23, four days before the start of the Muslim fasting month of Ramadan, they launched their attack when Philippine forces made an abortive attempt to capture Hapilon inside Marawi.

After the military retreated in the face of a phalanx of armed guards, about 400 militants quickly fanned out across the city, riding trucks mounted with 50-calibre machine guns and armed with rocket-propelled grenades and high-powered rifles.

Within hours, they attacked the jail and nearby police station, seizing weapons and ammunition, according to accounts from residents.

The Dansalan College, a Protestant institution, and the Catholic Cathedral of Maria Auxiliadora, were both razed, and a priest and about a dozen other parishioners captured. They remain hostages.

A Shi’ite mosque was also destroyed, and a statue of Jose Rizal, the Philippines hero of the uprising against Spanish rule, was beheaded.

SNIPERS ON ROOFTOPS

Herrera said the attack had the hallmarks of a professional military operation. “There was a huge, grand plan to seize the whole of Marawi,” he said.

After the initial battle, IS flags flew across the city and masked fighters roamed the streets proclaiming Marawi was theirs, using loud-hailers to urge residents to join them and handing out weapons to those who took up the offer, according to residents.

The military brought in helicopters to fire rockets at militant positions as ground troops began to retake key bridges and buildings, though some residents this has also led to the deaths of civilians.

“ISIS people were running on the street, running away from them. They were bombing them in the street (but) it hit our house and the mosque. Many other houses too,” said Amerah Dagalangit, a pregnant 29-year-old in an evacuation center near Marawi.

“Many people died when the bomb exploded,” she said, adding that a Muslim priest and children were among the victims.

Military officials said they had not received any report of the incident. Reuters could not independently verify the account.

The military has said 20 civilians have been killed in the fighting and that all were at the hands of the militants. It also says 120 rebels and 38 members of the security forces have been killed, including 10 soldiers who died from friendly fire in an airstrike.

“PEOPLE WILL GET KILLED”

Officials in neighboring Indonesia worry that even if the Filipinos successfully take back Marawi in coming days, the threat will still remain high.

“We worry they will come over here,” said one Indonesian counter-terrorism official, noting that Mindanao wasn’t very far from the Indonesian island of Sulawesi.

More than 2,000 people remain trapped in the center of Marawi, with no electricity and little food and water. Some are pinned down by the crossfire between the military and the militants, while others fear they will be intercepted by the militants as they flee, according to residents.

The bodies of eight laborers who had been shot in the head were found in a ravine outside Marawi last Sunday. The police said they had been stopped by the militants while escaping the city.

There will most likely be more civilian casualties in retaking the city, the military said.

“We are expecting that people will get starved, people will get hurt, people will get killed,” said Herrera, the military spokesman. “In these types of operations, you can’t get 100 per cent no collateral damage.”