The Philippine government has officially declared an end to the siege in the southern city of Marawi, ending five months of heavy clashes against ISIL-linked fighters and paving the way to recovery for a town left with more than $1bn worth of destruction.

Defence chief Delfin Lorenzana made the announcement on Monday, just hours after troops found the bodies of the last 42 fighters belonging to an armed alliance that had pledged allegiance to the Islamic State of Iraq and the Levant (ISIL, also known as ISIS).

{articleGUID}

"The Philippine security forces, aided by its government and the massive support of the Filipino people have nipped the budding infrastructure and defeated terrorism in the Philippines," Lorenzana said.

He made the comments during a meeting of regional defence ministers from the Association of Southeast Asian Nations (ASEAN) north of the capital, Manila.

Lorenzana said that while the end of the clashes "will not annihilate the [fighters'] ideology", it signalled the importance of regional cooperation in the fight against the "proliferation of terrorism" in the Philippines and its neighbouring countries in Southeast Asia.

'Only the first step'

More than 1,000 combatants, including foreign fighters, as well as civilians were killed in the fighting, which also displaced as many as 600,000 people in and around Marawi.

Zia Alonto Adiong, governor of Lanao del Sur province which has Marawi as its capital, said that while thousands of displaced residents are "rejoicing" at the prospect of going home, they should "not forget for a moment the toil and efforts that lie ahead".

"Achieving this victory does not mean the end of threats. Life is never free of dangers," he said in a statement to the media.

"We must recognise that the end of this war is only the first step toward building the peace."

The siege of Marawi began on May 23, when security forces tried to serve an arrest warrant against Isnilon Hapilon, the leader of the Abu Sayyaf armed group.

Instead of giving up their arms, Hapilon and his fighters formed an alliance with the local Maute Group - led by Omarkhayam Maute and his brothers - and took over the city by Lake Lanao.

Marawi's capture prompted President Rodrigo Duterte to declare martial law for the entire island of Mindanao.

At that time, the Philippine military insisted that ISIL had no presence in the country, contradicting Duterte's pronouncements that the attack "has long been planned" and was "purely ISIS".

It had also been widely reported that both the Abu Sayyaf and the Maute fighters had pledged allegiance to ISIL.

When the conflict started, the army vowed to end it within weeks, in a military campaign that included air raids.

It repeatedly set deadlines which, however, were missed and the clashes eventually lasted for five months - one of the longest active armed rebellions in the country.

Then, on October 16, government troops reached a breakthrough when soldiers stormed a hideout and killed Hapilon and Maute. A day later, Duterte declared the city "liberated", even as sporadic fighting continued.

'Rebuilding our lives'

The Philippine government estimates that it will need up to $1.1bn to rebuild Marawi.

In a statement to Al Jazeera, Senator Paolo Benigno Aquino, a member of the Marawi rehabilitation committee in Congress, urged the national government, local Muslim leaders and civic leaders to work to "rebuild and create prosperity in the city".

"We fully support efforts to rehabilitate Marawi City and to bring normalcy and prosperity into the lives of Maranao families," he said referring to the dominant Muslim ethnic group in the area.

{articleGUID}

Mikee Pantaran Maruhom, a student leader and a Maranao, said the end of the fighting is bittersweet for members of his extended family, whose houses in Marawi were destroyed by "government air strikes".

"The Marawi siege did not only affect Marawi residents, but also the entire Maranao community," he told Al Jazeera.

"For me, it is a great relief. I think my relatives who lost their homes also feel the same way. We can now actually move on to the next phase, which is rebuilding our lives," he said.

But like other Maranaos previously interviewed by Al Jazeera, Maruhom said the central government in Manila should address the root cause of the problem in Marawi, which is poverty and alienation.

Shidik Abantas, a lawyer at Marawi's Mindanao State University, had said the rise of "extremism" in Mindanao "is not really caused by the ISIS in the Middle East. It is mostly caused by the historical injustices that continue to this day."