When the US military abandoned its long-held bases in the Philippines in the early 1990s, it wasn’t because it wanted to. It was because the Philippines, as a sovereign nation, kicked it out. Filipino leadership decided the bases were unwelcome vestiges of the Philippines’ time as a US colony, which lasted for most of the first half of the 20th century.

If the US needed a reminder that the Philippines is an independent actor, it got a rude one this week, in a diplomatic sequence that shed light onto the nations’ up-and-down relationship.

“I am a president of a sovereign state and we have long ceased to be a colony,” said Philippine president Rodrigo Duterte. “I do not have any master except the Filipino people.” Not leaving well enough alone, healso called US president Barack Obama a “son of a bitch,” or the rough equivalent of that, in Tagalog.

Obama canceled an imminent meeting between the two, and Duterte later apologized for the comment, which followed a reporter asking him how he would respond if Obama brought up the issue of human rights in relation to Duterte’s dubious anti-drug campaign.

Despite the friction, an increasingly assertive China cements the underlying relationship between the two nations. The Asian giant claims most of the South China Sea as its own territory and has in recent years rapidly built artificial islands with military infrastructure, including on Mischief Reef, which is within the exclusive economic zone of the Philippines. Its forces also took over Scarborough Shoal, quite near the Philippine coast, and barred Filipino fishermen from accessing its rich fishing grounds.

Faced with such aggression, Manila recently agreed to welcome back US forces, giving them access to a handful of Filipino military bases via a 10-year deal called the Enhanced Defense Cooperation Agreement. The arrangement does not allow the US military to establish permanent bases of its own in the Philippines, but it does allow for a significant presence that Manila hopes will discourage further Chinese aggression.

Two of the bases hold special significance in relation to the South China Sea. Antonio Bautista Air Base, on Palawan Island, is the closest one the Philippines has to the contested Spratly archipelago, which includes Mischief Reef. Basa Air Base, just outside Manila, is across from Scarborough Shoal, where many have speculated China will soon begin building an artificial island.