Japan is the Philippines’ largest trade partner and aid donor. Both longtime American allies, the two nations are also embroiled in protracted maritime disputes with China. In August, Japan delivered a gift to the Philippines: a 44-m coast-guard ship so Manila can better patrol its contested territory in the South China Sea. Tokyo has promised at least nine other maritime-security vessels, along with the lease of surveillance aircraft.

So it made sense back in August when Philippine President Rodrigo Duterte, who took office in June, promised to honor Japan by making it the destination of his first foreign visit. But Duterte, whose changeable policies seem one of the few constants of his short tenure, quickly cast aside Japan. Instead, last week he embarked on a state visit to China and used the opportunity to proclaim his nation’s “separation from the United States, both in military, not maybe social, but economics also.” While Duterte softened his language upon returning to Manila, his China pivot was undeniable. Prior to his departure for Japan Tuesday, he warned — without elaborating — that the U.S. could forget about military cooperation were he to remain in power for longer.

“I look forward to the time when I no longer see any military troops or soldier in my country except the Filipino soldiers,” Duterte reportedly said.

Then Duterte hopped on the plane for Japan — these days always runner-up in the Asian geopolitical sweepstakes. Duterte’s trip to China was four days long. His Japan jaunt will be shorter by a day. The Philippine President wrangled $24 billion in investment and credit commitments from Beijing. In Japan, Duterte is expected to secure $48 million — yes, that’s millions, not billions — in loans for agricultural development in Mindanao, the southern Philippine island that is Duterte’s home. Overall, Trade and Industry Secretary Ramon Lopez says that Duterte’s trip to Japan will elicit around $2 billion in trade deals — $22 billion shy of China’s total commitments (although Beijing is notorious for not fulfilling its financial promises).

On Wednesday, Duterte will meet privately with Shinzo Abe, the hawkish Japanese Prime Minister who wants to beef up Japan’s armed forces to counter China. Regional security will surely be on the leaders’ agenda. While in Beijing, Duterte announced that he would resume bilateral talks with China on the South China Sea, which were suspended after China seized control of a contested shoal off the Philippine coast in 2012. In July, an international tribunal dismissed China’s vast claims over the South China Sea — a resounding legal victory for the Philippines that Duterte has taken pains play down, amid his overtures to China.

Tokyo is not one of the six governments jostling over control of reefs and islets in the strategic South China Sea. But like China, Japan depends on access to the South China Sea for most of its oil imports. So far, Beijing has not threatened commercial freedom of navigation in the South China Sea, even as it has marked out nearly all of the waterway as its own. Still, a geopolitically reconfigured seascape must spook Tokyo. Enmity between East Asia’s two great powers goes back centuries, but has been at its most vociferous over World War II. Beijing continues to hold Tokyo accountable for the imperial Japanese army’s brutal wartime occupation of China, and Abe’s nationalism has also only heightened the Chinese government’s public anger over historical grievances.

By contrast, the Philippines, which also endured a bloody Japanese occupation and witnessed such horrors as the Bataan Death March, is looking forward. On Thursday in Tokyo, Duterte will meet Emperor Akihito, whose father was emperor during World War II. Even as he railed against the U.S. and called President Barack Obama a “son of a whore,” Duterte praised Japan earlier this month for its years of assistance.

“Let me start by giving our sense of gratitude,” the Philippine President said, as he took ownership of the Japanese-made coast guard ship and noted past Japanese efforts to help Davao City, where he was mayor for 22 years.

“Now I’m the President and you continue to pour the aid that you feel you want to extend to us and again. I would like to thank Japanese people, the Emperor, and your government.”

Get The Brief. Sign up to receive the top stories you need to know right now. Please enter a valid email address. Sign Up Now Check the box if you do not wish to receive promotional offers via email from TIME. You can unsubscribe at any time. By signing up you are agreeing to our Terms of Use and Privacy Policy . This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply. Thank you! For your security, we've sent a confirmation email to the address you entered. Click the link to confirm your subscription and begin receiving our newsletters. If you don't get the confirmation within 10 minutes, please check your spam folder.

Contact us at letters@time.com.