Philippine President Rodrigo Duterte has warned he would deal harshly with militants, after declaring martial law on Mindanao island following a failed raid on a hideout of Isis-linked rebels.

Duterte cut short a visit to Russia and placed the southern island of 22 million people under military rule on Tuesday, and said he would keep it that way for a year if necessary.

Fighting abated in the mainly Muslim city of Marawi as troops sought to contain dozens of rebels of the Maute group, who escaped a botched raid on Tuesday on an apartment and took over streets, bridges and buildings and sought to block army reinforcements.

Duterte is a Mindanao native and has long threatened martial law to destroy two groups linked to Isis, which he warns is trying to gain a foothold in the Philippines.

He said the situation in Mindanao would be similar to the tough 1970s rule of late dictator Ferdinand Marcos, remembered by many Filipinos as one of the darkest chapters of their recent history.

“To my countrymen who have experienced martial law. It would not be any different from what President Marcos did. I'd be harsh,” Duterte said onboard a flight back to Manila, in a video sent by his staff.

“If it would take a year to do it then we'll do it. If it's over with a month, then I'd be happy. To my countrymen, do not be too scared. I'm going home. I will deal with the problem once I arrive.”

Two soldiers and a policeman were killed and 12 people wounded in Marawi, where Maute fighters took over buildings and set fire to a school, a church and a jail.

The military and government gave few details about the clashes nor did they say if any rebels had been killed.

Authorities insisted the situation was under control but residents who fled told a different story and said Marawi was in the hands of the rebels, who had allowed civilians to leave.

“The city is still under the control of the armed group. They are all over the main roads and two bridges leading to Marawi,” student Rabani Mautum told Reuters in nearby Pantar town, where some residents were leaving in overloaded trucks.

“I was in school when we heard gunfire... When we came out there were blood stains in the building but we did not see dead or wounded.”

Critics and even economists chided Duterte for what they saw as an overreaction in declaring martial law on an island the size of South Korea after an incident in one city.

Some activists expressed concern that it would lead to human rights abuses.

Martial law will last an initial 60 days. According to the constitution, Duterte has until Thursday night to explain his decision to congress.

He was due back in Manila on Wednesday afternoon.

Tuesday's raid was aimed at capturing Isnilon Hapilon, a leader of the Abu Sayyaf group notorious for piracy, banditry and for kidnapping and beheading Westerners.

The United States has since 2001 offered a bounty of $5 million for Hapilon's arrest. The military said they believed he had was wounded during the latest fighting.

The Maute and Abu Sayyaf have pledged allegiance to Isis and have proved fierce opponents for the military.

A photograph from one resident showed a black flag flying in Marawi that looked similar to that of Isis.

Duterte has warned repeatedly that Mindanao, an impoverished region beset by decades of unrest by separatist and Marxist guerrillas, was at risk of “contamination” by Isis fighters driven out of Iraq and Syria.

He has made development and foreign investment in Mindanao a priority of his presidency.

Armed forces spokesman Edgard Arevalo urged the public not to be alarmed if they saw checkpoints and soldiers.

“This is not a reflection of a major conflict looming, but this is a reflection of the capacity of our security forces to respond to any threat,” he said.

The most controversial quotes from Rodrigo Duterte Show all 9 1 /9 The most controversial quotes from Rodrigo Duterte The most controversial quotes from Rodrigo Duterte On killing drug addicts “These sons of whores are destroying our children. I warn you, don’t go into that, even if you’re a policeman, because I will really kill you. If you know of any addicts, go ahead and kill them yourself as getting their parents to do it would be too painful” The most controversial quotes from Rodrigo Duterte Message to China “I will go there on my own with a Jet Ski, bringing along with me a [Phillipino] flag and a pole, and once I disembark, I will plant the flag on the runway and tell the Chinese authorities, ‘Kill me’ ” AP The most controversial quotes from Rodrigo Duterte Christmas message to law-breakers “If you do not want to stop, and just continue committing crimes, then this would be your last Merry Christmas” AP The most controversial quotes from Rodrigo Duterte On sex life “I was separated from my wife. I’m not impotent. What am I supposed to do? Let this hang forever? When I take Viagra, it stands up” AFP/Getty Images The most controversial quotes from Rodrigo Duterte On the drugs trade “None of my children are into illegal drugs. But my order is, even if it is a member of my family, ‘kill him'" AP The most controversial quotes from Rodrigo Duterte Insulting the Pope “We were affected by the traffic. It took us five hours. I asked why, they said it was closed. I asked who is coming. They answered, the pope. I wanted to call him: ‘Pope, son of a wh**e, go home. Do not visit us again’” AFP/Getty Images The most controversial quotes from Rodrigo Duterte Joke about rape “I saw her face and I thought, 'What a pity... they raped her, they all lined up. I was mad she was raped but she was so beautiful. I thought, the mayor should have been first” AFP/Getty The most controversial quotes from Rodrigo Duterte Insulting Barack Obama "Mr Obama should be respectful and refrain from throwing questions at me about the killings, or son of a bitch, I will swear at you in that forum" REUTERS The most controversial quotes from Rodrigo Duterte On Abu Sayyaf Islamic militants "If I have to face them, you know I can eat humans. I will really open up your body. Just give me vinegar and salt, and I will eat you. If you annoy me to the fullest... I will eat you alive. Raw" EPA

He said the Maute group was showing off to Isis.

“They are merely courting the acclamation of Isis which until now they haven't received.”