Yoichi Funabashi is chairman of Asia Pacific Initiative, a Tokyo-based think tank.

“They looked like they were smelling each other’s socks.” That’s how Richard Armitage, a former U.S. deputy secretary of state, described the scene when Prime Minister Shinzo Abe of Japan and President Xi Jinping of China met for the first time in 2014, on the sidelines of an Asia-Pacific Economic Cooperation meeting in Beijing. No smile was cracked. No love was lost.

Sino-Japanese relations hit rock bottom in 2010 after a Chinese trawler rammed into Japanese Coast Guard boats in waters surrounding the Senkaku Islands (known as the Diaoyu in China), which both countries claim. Tense political relations without dialogue continued for years as economic ties were dangerously strengthened. The increasing interdependence of their economies over the ensuing years mismatched the strained political situation.

Abe’s state visit to China on Friday marked a return to normal Sino-Japanese relations. The two leaders presented a united front against protectionism and agreed to deepen economic cooperation. Beijing gave the Japanese leader a grand reception and Xi is considering a reciprocal visit.

This is a step in the right direction but there are certainly risks to Japan’s foreign policy. One is that Japan may be perceived as caving in to China. After opposing China’s land reclamation and military build-up in the East China Sea and South China Sea, as well as abstaining from the Asian Investment Infrastructure Bank, a Chinese-led development bank, on grounds of being a tool for Chinese economic statecraft, the strategic change of heart may reek of opportunism. If Japan is perceived by smaller Asian nations to be ceding to China, they could possibly do the same.

A second risk for Tokyo is that the meeting could be seen by Washington and the rest of Asia as a hedging strategy — an “insurance” policy, as put by a Chinese think tank delegation to Tokyo in April. Japan cannot afford to see any gains in its relationship with China become a wedge in its alliance with the United States.

Japan is trying to create a multilateral front with the United States, in line with World Trade Organization rules, to address China’s lack of reciprocity in economic relations and export its own standards. Abe repeatedly tried to persuade President Trump of the geopolitical importance of the Trans-Pacific Partnership in upholding the liberal economic trading order and of the necessity for trilateral cooperation with Europe to counter Chinese industrial policy. Both pleas were ignored.

He was told by Trump in private to leave tackling China’s economic policies to America, according to a a senior official in the Abe government. Separately, the president of the European Commission, Jean-Claude Juncker, was told exactly the same thing at the White House, a European ambassador to Tokyo told me.

Worse than the lack of cooperation, tariffs on automobiles and auto parts could cause a seismic rift with the United States and deal severe political damage to Abe, proving his “special relationship” with Trump futile.

The bilateral approach of the Trump administration points to the most fundamental risk in the triangle of U.S.-Japan-China relations as well as a reason underlying Abe’s visit: collateral damage from U.S.-China confrontation or collusion.

A continued trade war would compromise Japan, given that 21.7 percent of its trade last year and companies’ supply chains are tied to China. The Japanese government is also wary that the alliance with the United States will become subordinate to “new great power relations,” as was feared under President Barack Obama, perhaps in some form of deal that Trump might strike with Xi after the midterm elections.

As the U.S.-China trade war heats up, China needs Japan to play at least a buffer role, as well as gain political support for Japanese investment, which has been below half of 2012 levels in recent years.

Asian nations are likely to welcome warmer relations. Association of Southeast Asian Nations (ASEAN) diplomats tell me in private that tensions between China and Japan make them feel like they have to choose between them, something they detest.

While Japan appreciates that America is more willing to challenge China, the speed of the high-tech competition and a potential nuclear-arms race with China could push Japan to be played as a pawn and destabilize China-Japan relations. For Japan, it has become clear that managing relations with the United States is critical, and better relations with China is part of Japan’s attempt to retain some influence.

One thing is certain: Abe is determined to avoid the biggest toll of all – lasting damage to the U.S.-Japan alliance. The Japanese Ministry of Defense’s announcement on the inclusion of a submarine in military drills in the South China Sea is a timely signal that Japan will make no negative changes to the alliance and will do its part to uphold the rules-based order. Vice President Pence’s castigation of Chinese economic aggression and interference in American politics, which smacked of Winston Churchill’s 1946 Iron Curtain speech, did not fall on deaf ears in Tokyo.

If Abe can afford to reach normalization with China, it’s because of the lengths to which he has gone to strengthen the U.S.-Japan alliance. Even as he meets with Xi, Abe needs no reminder that Japan’s greatest long-term challenge is China.