Philippine President Rodrigo Duterte has never hidden his animus toward the United States. His tenure in Malacanang Palace has been marked by increasing belligerence toward his country’s ally and partner. For the most part, his bark was worse than his bite. That changed this week, with the announcement by Manila that it was ending an agreement with the U.S. that is essential to the functioning of the two countries’ security alliance. Duterte may decide to reverse course, but following through on his threat to terminate the Visiting Forces Agreement (VFA) could upend regional security arrangements — although not necessarily for the worse.

Since becoming president in June 2016, Duterte has waged a war of words with the U.S. He flatly stated that he is “not a fan of the Americans” and said that he wanted to end the Philippines’ foreign policy reliance on the U.S. In one rant, he called U.S. President Barack Obama “a son of a whore” and said he “could go to hell” after Obama criticized Duterte’s drug policy (which includes turning a blind eye toward, if not actively encouraging, extrajudicial killings of drug dealers and users). He called the U.S. a “so-called friend,” dismissing it as hypocritical and unreliable. He warned that “I will break up with America,” adding that “I would rather go to Russia and to China.”

Those were not empty threats. He has made multiple trips to China to meet that country’s leadership. He abandoned efforts to enforce the Permanent Court of Arbitration ruling that held that China’s “nine-dash line,” which Beijing insisted gave it authority over territory also claimed by the Philippines, was not grounded in international law. He has turned a blind eye to Chinese fishing in Philippine waters and played down incidents such as the ramming of a Philippine fishing boat by a Chinese vessel. His attitude is that “they do not mean harm” as long as “we do not also do something that is harmful to them.” All the while, Beijing has encouraged him with offers of financial assistance: In 2016, China pledged $24 billion in aid and investment to the Philippines.

Three factors drive Duterte’s thinking. The first is personal animus. The Philippine president is thin-skinned and quick to respond to any perceived slight. U.S. criticism of his human rights record infuriates him. One recent grievance is Washington’s refusal to grant a visa to Sen. Ronald dela Rosa, an architect of Duterte’s war against drugs. He is also said to nurse a grudge since being denied a visa to visit the U.S. while he was in college. U.S. President Donald Trump’s seeming indifference to human rights issues may have reduced one source of friction, but it has not been enough to change Duterte’s thinking about the U.S.

That could be a result of the second factor: Duterte’s doubts about the credibility of the U.S. commitment to the Philippines defense. The mercurial president is not alone in this concern. While the bilateral Mutual Defense Treaty (MDT) calls on both parties to “act to meet common dangers,” it has not been clear if that obligation extends to Philippine territories in the South China Sea. In the late 1990s, U.S. officials affirmed that Washington “considers the South China Sea to be part of the Pacific Area” and therefore any attack on Philippine “armed forces, public vessels or aircraft” there would be covered by the treaty. Subsequently, however, U.S. officials, including Obama, hedged, refusing to use the same direct language that they used when referring to the U.S. commitment to defend the Senkaku Islands under its alliance with Japan.

Philippine officials have called on the U.S. to clarify its thinking. Late last year, Secretary of National Defense Delfin Lorenzana called for a review of the MDT to ascertain whether it applies to the Philippines’ South China Sea territories. That seemed to get results. U.S. Secretary of State Mike Pompeo used the language that Manila sought during a February visit to the country.

More important is a new rhythm and tempo of U.S.-Philippine military cooperation. Despite the harsh rhetoric, by the end of 2018 bilateral security cooperation had returned to levels before Duterte took office, and it has accelerated after Pompeo’s visit. There are now more than 300 joint military exercises annually between the two countries. That has prompted a fear among some Philippine officials that renewed U.S. commitment could antagonize China.

Closer ties might be less helpful given the third factor: Duterte’s belief that China is the ascendant power in the region. Or, as he bluntly told Chinese leaders during a visit to Beijing: “America has lost now. I’ve realigned myself in your ideological flow.”

Rupture isn’t a done deal. While a spokesman for the president said that Duterte “will not entertain any initiative coming from the U.S. government to salvage the VFA,” other officials suggested that the move aims to shape negotiations over the relationship with the U.S. Significantly, other senior defense and foreign policy officials in Manila firmly believe that alliance with the U.S. is vital to the Philippines’ security.

Legislators insist that they must ratify any effort to end the treaty. (Technically, Duterte is not ending the treaty, but the VFA is essential to it; terminate the VFA and the treaty becomes almost impossible to administer. That is why the U.S. Embassy in Manila called the announcement “a serious step with significant implications.”)

If Manila is bluffing, or seeking leverage, it must be careful. The U.S. has walked away from the Philippines before: Unrealistic demands from Manila in base negotiations in the early 1990s ended the U.S. military presence at Clark Air Force Base and Subic Bay. Given Trump’s antipathy toward alliances, a hard-line stand could give him ammunition to end the treaty.

The end of the current U.S.-Philippines relationship would shake up regional security. Without a presence in the Philippines, the nearest land-based U.S. forces available in a crisis in the South China Sea would be more than 1,600 km away. But other governments might seize the moment to step up: When the U.S. left the Philippines nearly 30 years ago, Singapore offered the U.S. Navy access to its facilities at Changi. Vietnam could be similarly inclined today as might other Southeast Asian states troubled by aggressive Chinese actions and statements.

Just as important is the opportunity it gives Japan. Duterte holds this country in high esteem, making annual visits and calling Japan “a friend unlike any other”; he noted that “ours is a special friendship whose value is beyond any measure.” Japan has long been a key investor, export destination and source of assistance for the Philippines. Japan has built or financed much of the country’s infrastructure. Duterte developed close ties with Japanese businesses while he was mayor of Davao City and has forged a special relationship with Prime Minister Shinzo Abe, the first foreign leader to visit the Philippines after Duterte became president and who visited Duterte’s home in Davao.

Especially important are the increasing strength and resilience of security ties between the two countries. Under Abe, Japan has become a vital security partner, having made Manila a focus of its efforts to build capacity among Southeast Asian nations. It has gifted nearly a dozen vessels to the Philippine Coast Guard, along with reconnaissance aircraft and supplemented both with money for training, upgrades, maintenance and repairs. Since 2017, Japan has joined the annual Philippine-U.S. Balikatan exercises. Japan cannot replace the U.S. as a Philippine security partner, but it can play an increasingly useful role. Greater burden sharing and creative thinking about regional security will soon become the new norm.

Brad Glosserman is deputy director of and visiting professor at the Center for Rule-Making Strategies at Tama University as well as senior adviser (nonresident) at Pacific Forum. He is the author of “Peak Japan: The End of Great Ambitions.”