TOKYO—President Donald Trump’s tough line on trade with China has finally given Japanese Prime Minister Shinzo Abe something to agree with Beijing about.

After years of skirmishing with China over territory and security, Mr. Abe is promoting a rapprochement that reflects Tokyo’s need for allies in upholding the postwar free-trading system. It’s an example of how Mr. Trump’s “America first” policy of curbing imports he says threaten the U.S. are reshaping relations around the globe.

“I want to lift up the Japan-China relationship to a new stage,” Mr. Abe said at a news conference this month, describing a May visit to Japan by Chinese Premier Li Keqiang as “an important first step toward a dramatic improvement.”

Both sides in recent months have refrained from familiar denunciations in which Japan accuses China of trying to disrupt regional stability through force and China accuses Japan of ignoring the lessons of history through Mr. Abe’s military buildup.

During his visit, Mr. Li highlighted how Japan complements China as an export powerhouse, saying this results in “strong competitiveness in third-country markets” such as the U.S. He barely mentioned the historical issues that divide the two countries—Japan occupied much of China after invasions in the 1930s—and he repeated Tokyo’s favored formulation that the countries should “look to the future.”