Sharing an enemy has a magical way of forcing estranged allies back into each other’s embrace. In many ways, this is exactly what is happening to bilateral relations between the Philippines and the United States, as both nations grapple with the prospect of an Islamic State caliphate in Southeast Asia.

Throughout his first year in office, Philippine president Rodrigo Duterte rarely missed a chance to lash out at Washington and promote his distinct “Asia for Asians” approach to foreign relations.

Yet, shortly after back-to-back high-profile visits to Beijing and Moscow, which were part of his broader pursuit of an “independent” foreign policy, the tough-talking Philippine leader confronted a full-scale siege of Marawi, the country’s largest Muslim-majority city, by hundreds of ISIS-affiliated fighters, led by the notorious Maute group.

To the horror of the Philippine government, foreign fighters, coming from as far away as the Arabian Peninsula and the Caucasus, were reportedly involved in the Marawi attack. It is the first major attempt by the Islamic State’s regional affiliates to carve out actual territory and exert control over a large population anywhere in Southeast Asia. In response, the Duterte administration described the situation as a full-scale invasion and rebellion, declaring martial law across the entirety of Mindanao.

No stranger to threatening rhetoric, Duterte warned that he would be stern and “harsh” like former Philippine strongman Ferdinand Marcos, who ruled the country with an iron fist throughout the 1970s and early 1980s. The president also made it clear that he wouldn’t shy away from extending martial law across the whole country in order to “protect the people” against the threat of terrorism.

The tough-talking Philippine leader successfully ran on the promise of not only ridding his country of illegal drugs and criminality, but also bringing peace and development to the troubled southern island. In fact, he presented himself as the authoritative voice of the Moro (Muslim Filipinos). “I am running for president and I will fix Mindanao,” exclaimed Duterte during his fiery campaign rhetoric over a year ago. “Me, if I become president, if Allah gives his blessing, before I die since I am old, I will leave to you all a Mindanao that is governed in peace.”

Yet, a month into the battle for Marawi, the Philippine government has struggled to fully liberate the city from a hybrid legion of local and international jihadists. Inexperienced in urban warfare, the Philippine military has had to practically level large portions of Marawi to save it from the Islamic State. In recent days, Bangsamoro Islamic Freedom Fighters (BIFF), another Mindanao-based ISIS affiliate group, launched a daring assault in North Cotabato, attacking a primary school and taking hostages in several neighborhoods.

The latest spate of violence across the area is increasingly seen as part of a larger effort by extremists to establish an ISIS (province) in Southeast Asia.

Recognizing the depth of the crisis, the Philippine government has sought external assistance. As Philippine press secretary Martin Andanar told me in late May, the government is battling the “scourge and ideology of IS,” which is threatening the whole region. Weeks into the Marawi operations, the Philippine military sought American assistance, with the Pentagon providing real-time intelligence and deploying Special Forces to provide training and technical assistance for more effective counterterror operations.

The Pentagon has also provided a large volume of grenade launchers, automatic rifles and machine guns through a $150 million grant to in order to “enhance the [AFP’s] counter-terrorism capabilities, and help protect [those] actively engaged in counter-terrorism operations in [Marawi].” The Philippine military was particularly challenged by ISIS-affiliated fighters’ use of Improvised Explosive Devises and strategically placed snipers, while large-scale air raids led to friendly fire and concerns over civilian casualty. U.S. Special Forces and drones are meant to help the Philippine government deal with these operational obstacles.

Neither Moscow nor Beijing has counterterror experience comparable to that of Washington, which is currently leading an anti-ISIS coalition in Syria and Iraq—and, indeed, across the Middle East and North Africa. Since 2002, a large contingent of U.S. Special Forces has been based in Mindanao, aiding the Philippines against a myriad of extremist groups operating in the area.

As Adm. Harry Harris, commander of the US Pacific Command, told me during public exchanges on the sidelines of a major security summit earlier this month, “We are involved in activities in Mindanao to help the Armed Forces of the Philippines take the fight to ISIS in the Philippines. I think that is a recognition of how important our relationship with the Philippines is.” In many ways, America’s growing military presence in Mindanao is a major turnabout for a country whose leader threatened to expel American soldiers from his home island just few months ago. Duterte has gone so far as implying that the Philippine military unilaterally sought American assistance without his prior approval. Half-jokingly, Duterte lamented, “This is really their sentiment, our soldiers are really pro-American, that I cannot deny.”

A more nuanced analysis, however, shows that Duterte has always recognized not only the military’s preference for maintaining robust ties with America, but also its strategic necessity. “As we fought together to stay above the enemy, then so we should help each other to address the threats that confront our societies, our region and our world,” said Duterte, referring to the United States’ and the Philippines’ long history of military cooperation, just weeks before the attack on Marawi. Despite his anti-American rants, the Philippine president has been encouraged by friendly, if not fully sympathetic, rhetoric from the White House, which has vowed “support and assistance to Philippine counterterrorism efforts” as a “proud ally.” Asia’s already-volatile geopolitics just got a new plot twist.

Richard Javad Heydarian is an assistant professor in international affairs and political science at De La Salle University. He previously served as a policy advisor at the Philippine House of Representatives.

Image: A joint group of police and military forces guard while conducting a house to house search as part of clearing operations in different sections of Marawi city, Philippines June 7, 2017. REUTERS/Stringer​