Want smart analysis of the most important news in your inbox every weekday, along with other global reads, interesting ideas and opinions? Sign up for the Today’s WorldView newsletter.

President Trump promised a cozy personal relationship with Philippine President Rodrigo Duterte. After they first spoke in late 2016, Duterte said that the incoming U.S. leader approved of his bloody and controversial war on the Philippine drug trade. Trump said it was being handled in “the right way,” Duterte recalled.

On a personal level, common ground made sense. The two men share vulgar verbal styles, inflated egos and scorn of political correctness — not to mention a mutual dislike of former president Barack Obama.

Obama had criticized the Philippine leader on human rights, and Duterte repeatedly insulted Obama in response. But Trump didn’t push.

“We’ve had a great relationship,” Trump said when he visited Manila in November 2017, declining to answer questions about the startling toll of Duterte’s war on drugs, which has resulted in thousands of extrajudicial killings since it went nationwide in 2016.

But perhaps the two leaders were too alike for their relationship to last. This week, the Philippines took a step away from the United States, notifying Washington on Tuesday that it would end a major security pact that allowed American forces to train in the country.

Trump has dismissed the importance of the move, telling reporters Wednesday that it would save the United States money. But Defense Secretary Mark T. Esper warned that it is a shift in the “wrong direction” and analysts have said it could be a turning point in U.S.-Philippine relations.

Duterte’s planned withdrawal from the agreement was a death blow to U.S.-Philippine ties that “effectively ended his country’s century-old alliance with the United States,” Richard Javad Heydarian wrote for the Asia Times this week.

Implicit is something else: Despite the American overtures, the Philippines may be choosing Chinese President Xi Jinping over Trump.

Duterte’s move may have been a shock, but it shouldn’t have been a surprise. He for years has threatened to walk away from the Visiting Forces Agreement, or VFA, a pact that allows joint military exercises and a small number of U.S. troops to be stationed in the Philippines.

“I want, maybe in the next two years, my country free of the presence of foreign military troops. I want them out,” he said in Beijing in October 2016, a month before Trump’s election win.

Even before the colorful personalities of Trump and Duterte came to power, the military relationship between the United States and the Philippines bore a lot of baggage. After almost 50 years as a U.S. colony, the Philippines gained independence in 1946, and the two countries maintained joint military cooperation.

But in 1991, the Philippine Senate rejected a proposal to renew U.S. bases, prompting the withdrawal of the majority of U.S. troops from the country and the closure of the largest U.S. military base outside the United States.

The two countries kept a mutual defense treaty, despite its vague wording, and in 1999 they entered into the VFA, which was followed in 2014 by an enhanced agreement for increased cooperation. In recent years, as many as 100 U.S. Special Forces troops had been based on the Philippine island of Mindanao, helping in the fight against militants linked to the Islamic State.

The Philippines remained an attractive ally for the United States — the two countries shared history, as well as fears of Islamist extremism and a rising China. In the Philippines, opinions of the United States and Trump are far higher than in most countries. But the Philippines’ strategic location was, it turns out, also a curse for its relations with the United States.

With its proximity to China and interests in the disputed South China Sea, the Philippines has become a target for Chinese investment — Beijing has been developing the former Clark Air Base, first established by American forces during the Spanish-American War, into, among other projects, an airport.

Trump’s pushback on Chinese influence is one of his signature foreign policies. In that context, Duterte’s decision to withdraw from the VFA looks like a geopolitical loss for the U.S. president. “Beijing will certainly be happy with this,” said Jeffrey Ordaniel, assistant professor of international security studies at Tokyo International University.

“One of the very few options available for the U.S. to influence China’s behavior in the South China Sea, long-term, is to work with its alliance with the Philippines,” Ordaniel told Stars and Stripes, noting that other U.S. bases in the area are simply too far away to be of use.

But there may still be time to pull back: There are 180 days before the withdrawal from the VFA takes legal effect. Duterte made the move amid criticism from some Philippine lawmakers and even some in his government.

Despite the geopolitical implications, Duterte has framed the shift in more-personal terms, pointing toward a U.S. decision to revoke a visa for a former police chief, Ronald Dela Rosa, who had been implicated in extrajudicial killings during Duterte’s war on drugs.

Trump may say that Duterte’s push against U.S. troops has no impact, but he can’t knock the Philippine leader’s strategy. Duterte is ignoring the advice of domestic allies and rivals alike to play hardball in negotiations and conflating personal issues with geopolitics. Trump might admire it, if only he’d done it himself.