The martial law imposed in the southern island of Mindanao might be extended indefinitely, the Philippine president said Wednesday.

Rodrigo Duterte added the law might also be extended to the rest of the country if the terror threat escalates.

Duterte announced the measure Tuesday night after militants attacked the city of Marawi (north of Mindanao), killing three and wounding over ten.

The martial law will be withdrawn only after the police and the army have confirmed that the situation in Mindanao is stable, said Duterte at a televised press conference after shortening his Moscow visit and returning to Manila.

"We must move fast to restore normalcy. If it takes one week, I will be happy, but if it takes five years of my term, I will not withdraw it," said Duterte, referring to the martial law.

According to the country's current constitution, the martial law can be applied for a maximum period of 60 days, after which the Congress decides if an extension is required.

"If I think the ISIS has got a foothold in Luzon, I might declare martial law throughout the country to protect the people," Duterte asserted.

On Tuesday, militants from the Maute group - an organization linked to the Islamic State - had captured Marawi, a city with a population of 200,000 people, and laid siege on a hospital for hours, and set a church, a college and the city's prison to fire, while holding over 10 people hostage.

After several clashes, which killed three soldiers, the army claimed it has regained control over the city, even as tens of thousands of people were evacuated.

The Maute group is an Islamic armed organization based in Lanao del Sur that first emerged in 2012 under the name of Khilafah Islamiyah Movement (KIM), but adopted the name EI-Ranao two years later to indicate its affiliation with the IS.

Southern Philippines has been in the midst of a long-running separatist conflict that has killed between 100,000-150,000 people in the last four decades and has paralyzed the development of this resource-rich region.