Philippine President Rodrigo Duterte

Philippine President Rodrigo Duterte on Tuesday declared a southern city "liberated from terrorists' influence" but the military said the five-month battle against militants loyal to the Islamic State group was not yet over.

Duterte led rain-soaked soldiers in celebrations in Marawi, a day after the military announced the death of the head of the Islamic State group in Southeast Asia, Isnilon Hapilon, in a gunbattle in the city.

"Ladies and gentlemen, I hereby declare Marawi liberated from the terrorists' influence that marks the beginning of the rehabilitation," Duterte said, speaking moments after explosions and gunfire were heard in the city. 

"I promise you this will never happen again," he said as he gave troops a snappy salute.

Duterte stood on a gymnasium stage with a ruined roof near a tarpaulin bearing large photos of the dead militants. After he left, soldiers took selfies in front of a bombed-out building while others hoisted a Philippine flag atop a tank.

Military chief of staff General Eduardo Ano later clarified that the fighting against 20 to 30 remaining militants continued, describing them as "stragglers" and the clashes as "mopping operations". 

"The small number of the remaining enemy can now be considered a law enforcement matter and does not constitute (a) serious threat to hinder (rehabilitation)," Ano said in a statement. 

Troops persisted in efforts to rescue about 20 hostages, Colonel Romeo Brawner, deputy commander of the task force battling the militants, told AFP. 

Asked by reporters if Duterte's declaration was symbolic, Brawner said: "Yes, because we cannot really say that (the area) is 100 percent cleared." 

Pro-IS gunmen occupied parts of Marawi, the main Islamic city in the predominantly Catholic Philippines, on May 23 following a foiled attempt by security forces to arrest Hapilon.

Insurgents endured a relentless US-backed bombing campaign and intense ground battles with troops in the nation's longest urban conflict since World War II.

The military said Monday that Hapilon -- who figured on the US "most wanted terrorists" list -- was killed in a dawn offensive alongside Omarkhayam Maute, one of two brothers who allied with Hapilon to plot the takeover of the city.

Duterte had said Hapilon led an IS bid to establish a Southeast Asian caliphate as the jihadists suffer battlefield defeats in Iraq and Syria.

- Malaysian financier -  

Streets in Marawi were littered with machine gun bullet casings and rubble, including a van and twisted roofing sheets piled up on sidewalks. 

Troops were hunting a Malaysian militant, Mahmud Ahmad, who has been tipped to take over IS in the region following Hapilon's death.

The military said he was among six to eight foreign fighters in a battle zone comprising about 60 to 80 buildings.

"Mahmud remains... one of our high-value targets in the operations being conducted," said military spokesman Major-General Restituto Padilla.

Terrorism expert Ahmad Kumar Ramakrishna from Singapore's S. Rajaratnam School of International Studies said if Mahmud Ahmad survived he would likely take over the leadership of IS-linked fighters in the southern Philippines.

The militant is also reported to be a university lecturer in his home country who was in charge of raising finances from abroad for the jihadists and recruitment.

The restive south of the Philippines is home to extremist gangs which have declared allegiance to IS, including notorious kidnap-for-ransom group Abu Sayyaf and the Maute group.

On Tuesday the military warned against retaliatory attacks from sympathisers of the militants. 

The United States, a longtime defence ally of the Philippines, vowed on Tuesday to support the military's final push in Marawi. 

"The US Government will continue to work with the Armed Forces of the Philippines in the final phases of this operation, and looks forward to cooperating in assuring the stabilisation and rehabilitation of Marawi," US embassy press attache Molly Koscina told AFP.