What happens to small states on the front lines of a decaying international order? We can get a good sense by looking at the Philippines.

The last three years have seen a depressing erosion of Manila’s relationship with the United States and a weakening of its resistance to Chinese expansionism in the South China Sea. It is tempting to blame this on the eccentricities and excesses of President Rodrigo Duterte, who has ostentatiously snubbed Washington while courting Beijing. But this realignment really reflects a deeper belief that U.S. influence is declining as China’s ascendancy unfolds — and it could be a preview of a grim future in the Asia-Pacific region.

The U.S. and the Philippines have had a mutual defense pact since 1951, and the relationship has experienced ups and downs before. After the Cold War, the alliance fell into disrepair, with strong nationalist sentiment in the Philippines leading to the withdrawal of U.S. forces. Over nearly 20 years, however, American and Filipino officials worked to make the partnership real again.

As late as 2016, the Philippines was the centerpiece of America’s strategy in Southeast Asia. The two countries were implementing the Enhanced Defense Cooperation Agreement, which provided U.S. forces with access to five important bases in the Philippines. Manila had the lead role in the U.S.-funded Southeast Asia Maritime Security Initiative, meant to allow the countries of the region to better see and resist Chinese encroachment. U.S. and Filipino officials were bringing diplomatic and legal pressure against Beijing, hauling China before the Permanent Court of Arbitration over its illegal fishing and construction of artificial islands in the South China Sea.

Much has changed since then. Duterte rang in his presidency in 2016 by announcing his “separation” from the U.S. and his alignment with China and Russia. He called President Barack Obama a “son of a whore” after Obama mentioned the vast human rights violations Duterte was sponsoring as part of his bloody war on drugs.

After his inauguration, implementation of the defense agreement slowed and bilateral military exercises were temporarily downgraded. Even after the international tribunal ruled in Manila’s favor against China in July 2016, Duterte chose mostly to accommodate rather than resist Chinese pressure in the South China Sea. He also signed economic deals with Beijing running into the tens of billions of dollars, including an agreement that will allow a Chinese firm to build critical communications facilities on Philippine military bases.

Things subsequently stabilized a bit. Duterte backed away from early threats to kick U.S. forces out of the Philippines, perhaps because he realized that the military alliance actually helps him to drive a better bargain with Beijing. Day-to-day cooperation between U.S. and Filipino forces remains relatively strong.

Earlier this year, the annual Balikatan exercise simulated the repulsion of an amphibious assault by an unidentified country, although it’s hardly a mystery what invader the planners had in mind. U.S. forces also helped roll back an Islamic State siege of the southern city of Marawi in 2017. But Manila is clearly engaging in what political scientists call hedging: It is moving closer to Beijing while distancing itself from Washington.

Indeed, after Washington made a significant commitment to the Philippines in early 2019 — formally extending its protection to Manila’s armed forces operating in the South China Sea — Secretary of Defense Delfin Lorenzana publicly complained that America was trying to drag the Philippines into a war with China.

To some extent, this turmoil in the alliance is a result of Duterte’s bizarre behavior. A different president probably would not have undertaken a violent vigilante campaign to wipe out drug dealers and users, thereby straining the alliance over human rights issues. A different president might not have publicly insulted Obama’s mother or so flaunted his flirtation with Beijing. There are also allegations that Duterte and his cronies favor China because of the opportunities for corruption. To some extent, then, this rough period may simply reflect bad luck and the vagaries of democratic politics.

Yet this is not the whole story; the shakiness of the alliance is not just a matter of personality. It also reflects how greatly the regional balance of power is shifting — and that Duterte knows it. He and others are losing confidence in America’s ability to help the Philippines defend its interests.

This crisis of confidence has been building for years, even when bilateral cooperation was still improving. In 2012, the U.S. failed to stop China from wresting control of Scarborough Shoal, a ring of reefs less than 320 kilometers from the main Philippine island of Luzon. From 2013 to 2015, the U.S. did little to prevent China from building and militarizing artificial islands in the South China Sea.

Then, after Washington encouraged Manila to take its grievances to The Hague, it imposed no real consequences when China ignored the tribunal’s ruling. President Donald Trump later pulled the U.S. out of the Trans-Pacific Partnership, fueling doubts about America’s willingness to compete economically with Beijing. And although the Trump administration has carried out numerous freedom of navigation operations in the South China Sea, it has offered no solutions to Beijing’s creeping dominance of that waterway.

All the while, America’s military advantage has been eroding. Officials in the Philippines can read publicly available reports indicating that the U.S. would be hard-pressed to defend Taiwan right now. They can imagine what this might mean for the Philippines in the future. “America has lost” the struggle for influence in the Asia-Pacific, Duterte said in 2016. If the U.S. can’t check China’s bid for dominance, why should the Philippines take a hard line against Beijing?

This doesn’t mean all is lost. There is still a solid foundation of military-to-military ties.

Duterte’s anti-Americanism is not widely shared among Filipinos, and his successor will almost certainly be friendlier to Washington. Most Filipinos would surely prefer not to live in a region controlled by China. If the U.S. shows that it is serious about competing with Beijing — by making badly needed military investments, more sharply penalizing Chinese moves in the South China Sea, promoting better alternatives to economic reliance on China — it might get Manila back on its side.

Yet it is fairly late in the day. If the U.S. doesn’t quickly shore up its position in the Asia-Pacific, it will see more of this hedging, and not just from the Philippines. Duterte is like Trump: His outrageous behavior can distract us from what he really represents. If the U.S. doesn’t convince the countries of the region that it can hold its own against China, Duterte may represent the unhappy future.

Hal Brands is a Bloomberg columnist and a professor at Johns Hopkins University.