Referring to the siege of Marawi, the head of the West Mindanao Command in the Philippines told journalists this week: 'We knew this was coming.'

Since at least 2014, there's been no shortage of reports warning of the strengthening of the radical Islamist groups in the Philippines (here, here, and here, for example). When the Abu Sayyaf group's Isnilon Hapilon, now an Islamic State-designated emir, and several other groups in the Philippines pledged allegiance to Islamic State, there were obviously concerns radical Islamist forces would converge.

Yet, also in 2014, there was great progress made in the signing of the peace agreement between the moderate Moro Islamic Liberation Front (MILF) and the government, it was widely expected that the peace agreement would stabilise the southern Philippines, bringing in governance and economic growth that would smother extremism in otherwise moderate Muslim communities.

The siege of Marawi, now in its fifth week, has killed 375 and displaced some 350,000. It is a product of the Philippines' woeful politics. President Duterte is also product of those politics, but not the genesis. The dirty, do-anything presidential campaign in 2016 saw senators defame the hard-fought peace agreement designed to avoid today's very scenario. Duterte's own grubby brand of Trumpist politics has compounded these issues. His ill-conceived drug war has eroded the rule of law across the country, resulting in over 7000 extrajudicial murders. Aside from proving wholly ineffective, it has also complicated cooperation with regional actors on crucial regional issues - not a great outcome, given the opportunity presented to the Philippines as the current chair of ASEAN.

Just as misjudged has been the Duterte government's continued stalling of the 2014 peace agreement that would reward moderates in Mindanao. Indeed, it is a poignant reminder that the same kind of weariness that can drive an end to war can also drive an end to peace. 

As the government stalled on honouring commitments set out in the peace process, trust eroded. The space for extremism, previously small and containable by the MILF, began to grow. Numbers swelled for the splinter Bangsamoro Islamic Freedom Fighters (BIFF), who had pledged allegiance to Islamic State in 2014. Meanwhile, the Abu Sayyaf group, conducting a highly lucrative kidnap-and-ransom business in the south, and the Maute group, growing in influence and wealth, continued to recruit. Capitalising on divisions, the Abu Sayyaf group and the Maute group broke with traditional clan ties and coalesced along ideological lines. These groups were outward-looking and, in the case of the Maute brothers, educated abroad and proficient in Indonesian and Arabic, allowing contact with a wider audience. As such, the southern Philippines became an international staging ground for an Islamic State province, or wilayat.

For Islamic State, backing its allied groups in the southern Philippines was a win-win. Victory would create a new Islamic State franchise, while even moderate success in the form of a drawn-out campaign would (particularly if conducted in the midst of Ramadan) act as a core kinetic energiser for jihad in Southeast Asia. Having so far achieved their likely secondary objective in Marawi, Hapilon, the Maute brothers and the wider leadership (seen here), experienced in combat and supported by Islamic State, will now be able to better inspire, enable and direct attacks across the region. 

The failure by the Armed Forces of the Philippines (AFP) to act on early intelligence pointing to the Maute group's imminent attack on Marawi at the beginning of Ramadan was, at best, negligent. Its failings since - such as to apprehend the Malay financier of the Marawi campaign, to stop the escape of Hapilon, or simply to quell the insurgency - show a worrying lack of capacity. After weeks of stalling, Duterte has agreed to foreign support (including two Australian P-3 Orions).

Little about the fight for Marawi is actually about Marawi. Many of the militants and funding are from abroad, as is the narrative itself. Key to tackling this narrative in Southeast Asia will be a disaggregation, delinking and dismantling, of the militants from the global narrative. A starting point is the doubling down on the promises made in the MILF peace process, such as expediting the Bangsamoro Basic Law through congress in order to convey the message that the government will work more with Mindanao moderates – some important actions to this effect have already been achieved, including a joint AFP-MILF humanitarian corridor in Marawi. The reconciliatory message sent by Duterte over the Eid al-Fitr weekend, supported by an eight-hour ceasefire in Marawi so Muslims could celebrate the end of Ramadan, could be a sign the government now understands the importance of winning hearts and minds, rather than just bombing militants into submission. Other measures are also needed.

Scaling up joint patrols between MILF and army will support a cooperative narrative. Regional and international cooperation also needs to increase – joint maritime patrols, ignored for too long, should be well-resourced, regional, and routine. Other humanitarian assistance and disaster relief resources should be readied – typhoon season in the Philippines will continue through to November, threatening to compound the nation's problems and strain already limited capacity. In a case where limited resources need to be allocated between protecting populations in the Muslim south or elsewhere in the predominantly Catholic country, the wrong decision could play into a persecuted-minority narrative – a pull factor for militant recruitment. Similar to this is the very real chance of another organised criminal or insurgency group sensing the weakness of a distracted army and creating its own brand of problems.

Unshackling pledged aid money (Duterte rejected US$278 million in aid from the EU in May), even if it requires greater monitoring and reporting processes, should be top priority to avoid throwing previous aid recipients into poverty in the short term – a potential push factor for people to join paying Islamic militant groups.

Lastly, an end to the war on drugs, which has proved corrosive to the rule of law, would benefit Duterte's credibility internationally and support the legitimacy of the judicial system. 

All of these measures would ultimately work to strengthen the governance in the southern Philippines, but would also have far wider implications.

For the rest of Southeast Asia, this incident should be a lesson. Myanmar has the beginnings of a very similar and avoidable situation in Rakhine state (as I explain here and here). Thailand's escalating conflict in the deep south is equally avoidable, by engaging and enabling moderates rather than fighting them the government could stop further escalation.

The region now needs to deepen counter terror efforts. Rather than continuing the current trend of top-down authoritarianism and pandering to vocal extreme groups, the region must engage and enable grassroots moderates. It must start in Marawi.