MANILA — It was classic bravado from the Philippines’ tough-guy president, Rodrigo Duterte.

The Maute Group, a militant Islamist band fighting government troops near the southern Philippines city of Marawi last year, had asked for a cease-fire.

The president rejected the overture.

“They said that they will go down upon Marawi to burn the place,” Mr. Duterte recounted in December. “And I said, ‘Go ahead, do it.’”

He got his wish.

Hundreds of militants belonging to the Maute Group and its allies fighting under the black flag of the Islamic State, also known as ISIS, seized Marawi three weeks ago, leading to a battle with the Philippine armed forces and the biggest test yet of Mr. Duterte’s leadership during his tumultuous first year in office.

A president who has focused on a deadly antidrug campaign that has claimed the lives of thousands of Filipinos seems to have been caught unprepared for a militant threat that has been festering in the south for years.