As the black flags of the Islamic State of Iraq and al-Sham (ISIS) fall in Iraq and Syria, new ones have been raised in the Philippines. That ISIS is losing its battle for territory in its home countries, Iraq and Syria, is indisputable. ISIS leaders have admitted that the “caliphate” will soon fall. However, the defeat of ISIS in Iraq and Syria is unlikely to be the end of the group as an active terrorist organization. Rather, as ISIS loses power in its traditional territories, it seems to be spreading its extremist ideology through other terrorist groups around the world, including those in the Philippines.

In May, an Islamist group affiliated with ISIS seized control of the Philippine city of Marawi. In this way, ISIS is embracing a “franchise model” similar to that employed by al Qaeda (AQ) following the US response to the terrorist attacks of September 11, 2001. This franchise model allows the original faction of ISIS to maintain ownership of a disparate grouping of extremist divisions around the world, thereby ensuring its survival.

At its inception in 2013, ISIS broke off from its former affiliation as al Qaeda in Iraq (AQI), and became a geographically contiguous entity. Today, ISIS, also known as the Islamic State, has fully operational branches in eighteen countries, and aspiring branches in six more, including the Philippines.

Since the 9/11 attacks, US counterterrorism efforts have largely handicappedthe founding AQ organization, and ISIS is beginning to struggle under similar constraints, with the death of key leaders and the fall of crucial cities such as Mosul to Iraqi security forces. However, the ready-made, well-known, and widely-propagated doctrine, ideology, and structure of ISIS has lent itself well to AQ-style franchising, and projects a disproportionate image of ISIS’ strength on the global stage. That ISIS can lend its name to a group as far away as the Philippines is testament to the strength and durability of the organization’s brand, despite setbacks at home.

For this reason, ISIS will likely continue to be a threat in the near future. As it continues to evolve in the face of high international resistance and pressure, ISIS will seek to change the battlefield and adapt its structure to survive, demonstrated by its expansion to the Philippines.

The Philippines has a long history of dealing with terrorism, with the Moro National Liberation Front (MNLF) and its later splinter group Moro Islamic Liberation Front (MILF) fighting against the government for independence until their recent ceasefire. Despite support from foreign governments like Libya and Malaysia, these groups have negligible ties with ISIS. However, recent smaller splinter groups like Maute and Abu Sayyaf, which are involved in the current occupation of Marawi, have cooperated under ISIS’ banner.

Isnilon Hapilon, the leader of Abu Sayyaf, was proclaimed last year to be ISIS’ emir of Southeast Asia, establishing him as the leader of the ISIS franchise in the region. However, while Hapilon and his allies in the Maute group have pledged allegiance to the Islamic State, it is still unclear how many individual fighters on Mindanao are actually affiliated with ISIS. Maute and Abu Sayyaf appear to be pursuing their original goals and operating with a high degree of independence, the same way that the franchise model operates.

As he addresses the host of new challenges raised by ISIS’ presence in the Philippines and attempts to mitigate the potential regional repercussions, Philippine President Rodrigo Duterte, a leader with an extremely poor human rights record, must avoid alienating both his nation’s Muslim citizens and its allies abroad. In response to the invasion of Marawi, on the island of Mindanao, Duterte declared martial law on the island. This approach to handling the insurgency risks alienating those at home and abroad. In light of his violent war on drugs that has left thousands dead since June of 2016, Duterte’s threats to put aside human rights while combating ISIS will likely increase the degree of international scrutiny to which he is subjected. International criticism has already cost the Philippines aid from the United States.

Further, Duterte’s proposal to pay fighters of other Filipino rebel groups to counter ISIS presents a wide array of associated risks. He offered to hire rebel fighters as soldiers with the same pay and privileges as regular soldiers, even offering to build houses in some areas. This plan jeopardizes the recent and fragile peace treaties between the government and groups like the MILF and MNLF. The risky strategy has the potential to embolden non-ISIS rebels to break the recent ceasefires and fight what they perceive as a weakened Philippine state.

At best, Duterte’s plan could damage the ISIS brand by demonstrating that other Islamic militant groups are willing to fight it, and could ingratiate the president to Filipino Muslims. However, ISIS has fought other Islamic groups in the past without damaging its reputation. At worst, the use of rebel forces could legitimize violent insurgency and promote further excessive and extrajudicial violence on behalf of Duterte. Particularly with recent US involvement in the conflict, the Philippines is unlikely to need the support of rebel groups, and now can use US resources as an alternative to members of insurgent groups involved in the current ceasefire.

The Philippine military involved in the recapture of Marawi must also be careful to differentiate between its true opponents and innocent citizens of the Muslim-majority area. Terrorist recruiting is most successful when immigrants and minorities feel excluded and alienated. Therefore, Duterte must be sure his soldiers take aim only at those truly responsible for the violence, and avoid creating more enemies in the future by targeting civilians or instituting policies that could be seen as discriminatory. Declaring martial law can certainly help in the effort to retake Marawi right now, but its implementation must be carefully managed in order to minimize the potential risk of Muslim Filipinos feeling targeted by law enforcement.

There are some potential benefits to using other rebel groups to fight ISIS but the associated risks far outweigh the benefits. According to Duterte, Nur Misuari, the founder and leader of the MNLF has offered military aid. In addition, Islamic insurgent groups fighting against ISIS-backed rebels could help to damage ISIS’ brand as well as create the impression that Duterte is willing to work with and accommodate the Filipino Islamic community. However, supporting rebels of any kind is risky, a lesson the United States has learned many times. There is no guarantee that the newly armed rebels will not see a chance to replace Maute, a rival group, after defeating them, or otherwise turn against the government. As evidenced by the long and arduous events of the recent Colombia peace talks between the government and guerilla fighters in 2016, true peace is by no means guaranteed, and even if a ceasefire can survive there will be tension. Moving this quickly from peace talks to military cooperation with a rebel group in one’s own country is uncharted territory, and could have catastrophic consequences.

The success or failure of Duterte’s efforts to recapture Marawi and the long-term results in the fight against terror will be critical to gauging the potential expansion of ISIS and other extremist groups in Southeast Asia. The battle for Marawi reflects changing environments for terrorist groups as well as ISIS’ ability to be agile and flexible in how it adapts to them. How the Philippines manages this new destabilization and the long-term effects will be valuable lessons for other countries outside of the Middle East in how to prevent extremist influence from manifesting itself as ISIS seeks to ensure its survival.

Adam Petno is an intern at the Atlantic Council’s Brent Scowcroft Center for International Security.

This article appeared originally at Atlantic Council.