JAPAN has been more unsettled than any other country by the sudden shift in the diplomatic tone in North-East Asia—for good reason. President Donald Trump shocked America’s biggest Asian ally in March when he accepted an offer to meet Kim Jong Un, North Korea’s dictator—a step that seemed to deviate from his previous policy of unyielding pressure on North Korea to force it to abandon its nuclear programme. The casual way Mr Trump blindsided Shinzo Abe, Japan’s prime minister, suggested that he did not especially value America’s alliance with Japan. Japan has since looked on, as South Korea takes the lead in whirlwind diplomacy on the Korean peninsula, the North’s overtures to America grow ever warmer (on May 9th it released three Americans held in North Korea) and China tries to shape any evolving deal. Xi Jinping, China’s president, has twice hosted Mr Kim, most recently in the port city of Dalian on May 7th and 8th.

That goes a long way to explain the warmth, as well as the relief, with which Mr Abe welcomed Li Keqiang, China’s prime minister, and Moon Jae-in, South Korea’s president, to Tokyo on May 9th. It was the three countries’ first trilateral meeting in two-and-a-half years, even though the first such powwow, in 2008, was heralded as an annual event. Because Japan is unsure whether it can rely on Mr Trump, who is expected to see Mr Kim next month, it is courting its neighbours. And though relationships often run aground on historical and territorial disputes, the Asian trio are finding more reasons to be pragmatic, irrespective of North Korea. One big force pushing them together is uncertainty about America’s role in the Pacific and its growing threat to open trade.

At a time when China’s tremendous growth is slowing and a trade war with America is brewing, China is eyeing investment and technical expertise from Japan, not least to help its Belt and Road initiative, an ambitious project to finance billions of dollars of infrastructure development along the old Silk Road. Japan has a rival plan for economic prosperity in the region, but sees opportunities in China. The three leaders say they will work on bilateral, trilateral and multilateral free-trade agreements.

Economics aside, Mr Xi appears to realise that China needs smoother relations with its neighbours to project soft power. On May 4th he and Mr Abe had the first-ever phone call between a Japanese prime minister and a Chinese president. China has stopped punishing South Korea for playing host to an American missile-defence battery and this month restarted bilateral defence talks after a two-year hiatus.

Japan and South Korea, another close American ally, are similarly united by fears of a trade war, but relations are currently driven by diplomacy over the Korean peninsula. Where Mr Trump would once call Mr Abe ahead of Mr Moon whenever North Korea fired a missile, the Japanese leader now feels he needs a hotline to Mr Moon to be kept in the loop. For his part, Mr Moon, bent on reaching a deal with North Korea, does not want Japan to ruin it. So he has urged Mr Abe to talk to the North as well. Mr Moon said he had tried to help Mr Abe at last month’s summit between the two Koreas by raising an issue that animates him: the fate of Japanese citizens abducted by North Korea in the 1970s and 1980s.

Diplomacy over the Korean peninsula is tricky for all three leaders. They all agree that the North should give up its nuclear weapons. But they differ over what “denuclearisation” means and how to get there. Mr Abe wants to keep up the pressure on North Korea until its weapons are gone, while South Korea is already exploring the idea of resuming economic ties. China above all values the stability of the North Korean regime; Chinese media suggest that Mr Xi, in his latest meeting with Mr Kim, may have endorsed the idea of phased disarmament by North Korea in exchange for a series of concessions from America.

Japan clearly deserves a say. Along with South Korea, it is most vulnerable to North Korea’s missiles. It was one of the six parties in talks with the North from 2003 to 2008. It would be expected to open its wallet, should a deal be struck with North Korea that involves economic assistance. And it fears a nightmare scenario in which Mr Trump strikes a deal with Mr Kim to get rid of long-range missiles while letting him keep shorter-range ones that could still hit Japan.

North Korea is enjoying watching Japan squirm. Rodong Sinmun, the official newspaper of North Korea’s ruling Workers’ Party, likes baiting Japan. Mr Abe, it writes, will not be granted a meeting with Mr Kim unless Japan drops its “inveterate repugnancy” that leads it to stress sanctions and pressure. Japan is right to be sceptical about North Korea’s sudden conversion to disarmament, says Daniel Sneider of Stanford University, but the danger of Japan’s hedging is also clear. “If the summit goes well between Mr Trump and Mr Kim, Japan will have to make its way on its knees to Pyongyang.”