At first glance, the endless rows of devastated buildings could be the aftermath of a great earthquake. But the punctured, bullet-riddled walls tell the true story of the Philippines' longest urban war.
"No one wanted this to happen," President Rodrigo Duterte said on Tuesday as he declared Marawi city "liberated from the terrorists' influence" after a nearly five-month battle with gunmen loyal to the Islamic State group.
A day earlier troops had tracked down and killed the Islamic State "emir" for Southeast Asia -- Isnilon Hapilon, leader of the militants.
The battle for the southern city, the Islamic capital of the mainly Catholic Philippines, lasted more than four times longer than the US-led campaign to liberate Manila from Japanese World War II occupation forces.
In the process the military literally destroyed Marawi to save it from gunmen it says are intent on carving out territory for a Southeast Asian caliphate.
An AFP team saw metal shutters and walls pockmarked with bullet holes, pavements piled high with twisted metal and cannibalised cars, and streets strewn with machine-gun slugs.
The scenes evoked pictures of destruction in war-torn Middle Eastern cities like Aleppo and Mosul.
- New urban warfare -
Defence Secretary Delfin Lorenzana estimates the government will need $1.1 billion to rebuild the city.
On the ground floor of some buildings, soldiers peered warily at the street through holes just big enough for men to crawl through.
These gaps are evidence that the militants who seized the city on May 23 -- estimated by military officials to have numbered one thousand -- brought in a new style of urban warfare that initially flummoxed Filipino troops.
The militants blasted rat holes through walls to turn hundreds of densely built buildings in the city centre into a maze of improvised tunnels to evade relentless air strikes as well as US and Australian spy planes and drones.
They seized hostages, using some as human shields and others as cooks, medics, or grave diggers for dead gunmen.
They also forced captives to loot houses for cash and weapons and even to fight alongside them, the military said.
"These terrorists are using combat tactics that we've seen in the Middle East," US Pacific Command chief Admiral Harry Harris told a security forum in Singapore on Tuesday.
It also marked the first time that IS-inspired forces had banded together to fight on such a scale in the region, he added.
- Foreign fighters -
Of the more than 1,000 dead, the Philippine military and police lost 164 men, with more than a thousand soldiers wounded in house-to-house combat.
Most were hit by improvised explosive devices, snipers and firebombs, as well as shoulder-fired rockets used against armoured vehicles.
Forty-seven civilians were killed, while nearly 400,000 others fled their homes, according to official tallies.
Following his speech in Marawi, Duterte apologised to the region's displaced residents. "We did not wish this on you... but the circumstances really compelled us to act," he said in the eastern city of Pili.
The authorities said they believed the gunmen -- some of them foreign fighters from nearby Malaysia and Indonesia or as far as Chechnya -- stockpiled weapons and food for weeks and possibly months before seizing the city.
The militants also turned mosques, off-limits to air strikes and artillery, into sniper's nests, munitions depots and hiding places, authorities said.
"At the start we were surprised because we were used to fighting in the mountains and areas away from population centres," Philippine military chief General Eduardo Ano told Radyo Singko radio station in Manila on Wednesday.
The troops gradually adapted to the new enemy's tactics while acquiring better-suited equipment, including sniper rifles and armoured vehicles, he added.
Some 882 militants were killed, the military said, with fighting continuing Wednesday at a district near the shore of nearby Lanao lake.
The military said the gunmen had used the large lake as a supply route for food, fuel, weapons and manpower. It then became an escape route as the security noose tightened on them in recent weeks.
Authorities have declined to give a timetable for the return of the displaced residents.
Apart from the job of restoring electricity and tap water, there are concerns about potential fresh infiltration of militants, said Zia Alonto Adiong, a spokesman for the Marawi local government.
"We don't want another incident that would force us to go on evacuation mode again," he told reporters.