BEIJING — Shared trade friction with the U.S. appears to be drawing longtime Asian rivals China and Japan closer, with Chinese President Xi Jinping telling Japanese Prime Minister Shinzo Abe on Friday that the two countries are “sharing more common interests and concerns.”

China-Japan relations have undergone turbulence but are now “back to a normal track,” Xi told Abe during the first formal visit to Beijing by a Japanese leader in nearly seven years.

“Under the new situation, our interdependence with each other has deepened. Also, we are sharing more common interests and concerns in multilateral and wider areas,” Xi said.

Abe’s visit highlights the improvement in ties after they hit a low in 2012 during a dispute over East China Sea islands controlled by key U.S. ally Japan but claimed by China.

While that feud remains unresolved, trade and investment have recovered and companies from the two sides are exploring joint investments in third countries such as Thailand.

“Under the new situation, our interdependence with each other has deepened.”

China has come under increasing pressure from U.S. President Donald Trump’s move to impose punitive tariffs on $250 billion in Chinese products and attempt to limit Chinese access to American technology. Beijing has responded with tariffs of its own on U.S. goods such as soybeans, and no swift resolution to the standoff appears likely.

Trump has also raised tariffs on imports of steel and aluminum from Japan and other countries, and is threatening tariffs on Japanese autos and auto parts. That seems to be prompting both countries to look for alternative markets and cooperate on foreign investments where their interests converge, despite their longstanding disagreements.

“In the past several years, the China-Japan relationship has experienced ups and downs. With the efforts made by both parties, our relationship has been straightened out and come back to a normal track,” Xi said.

Abe responded that Japan believes the two countries should take a free and fair trade system to “a new level.”

“Based on these principles, Japan and China need to work together and contribute to what the world in a sense expects of us, toward the peace and stability of the region, and that of the world,” Abe said.

Prior to meeting Xi, Abe met twice with Chinese Premier Li Keqiang to discuss issues ranging from the East China Sea dispute to trade cooperation and human rights, according to Abe spokesman Takeshi Osuga.

Speaking to reporters afterward, Li said 500 business agreements worth $18 billion had been signed between Chinese and Japanese companies during the visit, displaying the “bright future” for cooperation between the sides. Osuga said he could not confirm that figure, saying they were purely commercial arrangements reached by the companies involved.

Abe, who has been accompanied on his visit by a 500-strong business delegation, expressed hopes for closer ties and a shift in relations from “competition to cooperation,” an apparent reference to the rifts that until recently have muted Japanese business interests in China.

The visit, which featured Japanese flags hung in the heart of Beijing, marks a dramatic outward improvement in ties from six years ago.

Anti-Japanese riots broke out in China after Tokyo nationalized the islands, called Senkaku by Japan and Diaoyu by China, and Beijing froze high-level contacts. Tourism, trade and investment dropped off and Japanese-brand vehicles and other products were vandalized or destroyed.

Asia’s two largest economies appear to have shelved differences in favor of business ties.

Ties have also been dogged by enduring Chinese resentment over Japan’s invasion and occupation last century and a political, military and economic rivalry for influence in Asia and beyond.

Speaking at a briefing for reporters, Osuga said ties had recovered from what had been “not normal relations with a neighboring country,” but said differences remained. That is particularly true in the East China Sea, where in addition to the islands, China and Japan are at odds over the exploitation of natural gas and other resources.

“Prime Minister Abe reiterated his view that, without stability in the East China Sea, there will not be a true improvement of the relationship,” Osuga said.

“The two leaders shared the view that there needs to be concrete progress in the field of maritime domain as balancing the security field, to build a constructive relationship and to get rid of the mutual distrust between the people of the two countries,” he said.

To further that, the sides agreed to hold a meeting by the end of the year to discuss ways to avoid confrontations in the air and at sea, and also signed an agreement on search and rescue cooperation, Osuga said.

He declined to give details about the leaders’ discussions on the territorial dispute, human rights and other sensitive issues.

Japan this year terminated four decades of government assistance to China, considered by some as a type of reparations for the damage caused during its invasion and occupation. As China’s economy surged past Japan’s to become the world’s second largest, such assistance appeared increasingly anachronistic, although Japan had continued to provide funds for problems such as health and air pollution that affect the region as a whole.

For now, however, Asia’s two largest economies appear to have shelved differences in favor of business ties. China is already Japan’s largest trading partner and Japanese companies from carmakers to department stores play a major role in the Chinese economy.

Abe, who also attended a third-country investment conference and met with students at elite Peking University, is to return to Japan on Saturday. The last such visit was in late 2011.

Xi is expected to visit Japan next year, with Abe returning to China to attend a trilateral summit of the leaders of China, Japan and South Korea.