The violence on the southern island left three members of the security forces dead, officials say.
Mindanao is home to a number of Muslim rebel groups seeking more autonomy.
Mr Duterte made the announcement during a visit to Russia, which he was forced to cut short.
Martial law allows the use of the military to enforce law and the detention of people without charge for long periods.
During his talks with Russian President Vladimir Putin, Mr Duterte also said the Philippines needed more modern weapons to fight IS militants and other militant groups.
The violence in Marawi, a city of about 200,000 people in Mindanao, erupted on Tuesday as the army searched for the leader of a militant group that had pledged allegiance to IS, the military said.
Defence Secretary Delfin Lorenzana identified the militants as members of the Maute group. They had occupied a hospital and a jail, and burnt down buildings including a church, he added.
Marawi is about 800km (500 miles) south of the capital Manila.
The Philippine constitution says a president can only declare martial law for 60 days to stop an invasion or a rebellion.
Parliament can revoke the measure within 48 hours while the Supreme Court can review its legality.
Philippine President Rodrigo Duterte has declared martial law for 60 days on the island of Mindanao, after clashes between the army and militants linked to so-called Islamic State (IS).