"I had to declare martial law in the Mindanao group of islands," Duterte said at a news conference Wednesday. "It is our constitutional duty to enforce the law and provide security."
Duterte's order -- which covers both the city of Marawi and the wider island of Mindanao, of which Marawi is a part -- came after deadly clashes broke out between Filipino government troops and Islamist militants Tuesday.
If the terror threat spreads, Duterte said he's not afraid to go further.
"If I think that the ISIS has already taken foothold also in Luzon and terrorism is not really far behind, I might declare martial law throughout the country to protect the people," said the President, who cut short a visit to Russia to come home to deal with the violence.
Fighting between government forces and the Maute group, an Islamist militant organization based in Mindanao, began in Marawi, a city of about 200,000 people.
ISIS' media wing, Amaq Agency, put out a statement announcing that "fighters of the Islamic State launch a wide-scale offensive on positions of Philippine troops in the city of Marawi."
Presidential spokesman Ernesto Abella confirmed that the fighters had taken over several government buildings in the city, and had torched others, including a church, a school and the city jail. It was not clear from his statement how damaged the buildings were by the arson.
Mindanao is home to a sizable Muslim population, in contrast to the remainder of the country, which is overwhelmingly Catholic.
The militants also reportedly took over a medical center and replaced the Philippines flag with a black, ISIS-style banner.
Armed Forces of the Philippines (AFP) spokesman Lt. Col. Jo-Ar Herrera said that Isnilon Hapilon, the leader of the Abu Sayyaf Group, which has pledged allegiance to ISIS, was among the armed men.