"We now announce the termination of all combat operations in Marawi," Defence Secretary Delfin Lorenzana told reporters on the sidelines of a regional security meeting in Clark, a northern Philippine city.
Lorenzana said there were no more militants, known locally as coming from the Maute group, providing resistance following an intense final battle after which 42 bodies were recovered.
More From This Section
"Those are the last group of stragglers of Mautes and they were caught in one building and so there was a firefight so they were finished," he said
"All terrorists, fighting troops. All hostages have been recovered."
Hundreds of gunmen who had pledged allegiance to IS rampaged through Marawi, the Islamic capital of the mainly Catholic Philippines, on May 23, then took over parts of the city using civilians as human shields.
Philippine President Rodrigo Duterte and security analysts said the militants were trying to establish a Southeast Asian caliphate in Marawi.
The ensuing US-backed military campaign to evict the militants claimed more than 1,000 lives, displaced 400,000 residents and left large parts of Marawi in ruins.
Duterte travelled to Marawi on Tuesday last week and declared the city had been "liberated", shortly after the Southeast Asian leader for IS, a Filipino militant named Isnilon Hapilon, was shot dead there.
However the continued fighting raised questions over whether the city was indeed free of the militants.
US Defence Secretary James Mattis today praised the Philippines for its success in Marawi.
"One of the first things I'm going to do when I get there is commend the Philippine military for liberating Marawi from the terrorists," Mattis told reporters on board a flight to the Philippines to attend the security meeting in Clark.
"It was a very tough fight as you know in southern Mindanao (the local region). And I think the Philippine military sends a very strong message to the terrorists."
Hapilon, who was on the US government's list of most- wanted terrorists, was killed along with one of group's other leaders, Omarkhayam Maute, according to the military.
Hapilon and Maute, along with hundreds of other militants, had been able to defy near daily bombing raids that left much of the city in ruins by sheltering in basements and travelling through tunnels, according to the military.
The impoverished southern Philippines, home to many of the nation's Muslim minority, has for decades endured conflict.
The nation's biggest Muslim rebel group is in talks with the government to end a rebellion that began in the 1970s and has claimed more than 120,00 lives.