Money and power are combining to create a tentative thaw in the relationship between Asia’s two biggest economies.

After more than two years of tensions, Chinese President Xi Jinping is making a careful rapprochement with Prime Minister Shinzo Abe, who has long called for improved ties. Whether it lasts depends much on what Abe says in August about his country’s wartime past.

A number of factors have spurred the shift. China’s economic growth is slowing while Japan, a big investor, is sending less money in. And Xi has consolidated enough power within the Communist Party and military to take a softer stance on a longtime foe with less risk of a backlash at home.

The ramifications are potentially significant. Lowering tensions will provide room for a pickup in trade and investment. China and Japan may work more closely to contain the rogue regime of North Korea. It could also limit the friction between China and the U.S. — a key ally of Japan that’s obliged to defend it in the event of a conflict.

The next test will come in August when Abe issues a statement to mark the 70th anniversary of World War II. He has said he stands by, but won’t repeat, past apologies. Whether that is enough for China — a country Japan invaded — is open for debate, though Abe also avoided a direct apology in a speech in Jakarta and still sat down with Xi shortly afterward.

“Things have got considerably better,” said Wang Xueping, an associate professor at Toyo University in Tokyo. “In particular, rather than the Japanese side, we can see a softening of the Xi administration’s policy toward the Japanese government,” she said. “The Xi administration’s policy toward Japan had been rigid, but recently they have begun to treat the Japanese government and the people separately.”

While China and Japan have often been troubled neighbors, ties soured badly in 2012 over disputed islands in the East China Sea to the point it affected trade. Abe compounded tensions by visiting Yasukuni Shrine, which honors Japan’s war dead, as well as World War II Class-A war criminals. For its part, China in late 2013 announced an East China Sea air defense identification zone and repeatedly criticized Abe’s plan to expand the remit of Japan’s military.

The current detente follows months of behind-the-scenes negotiations and a flurry of lower-level meetings.

A frosty November handshake between Abe and Xi on the sidelines of an Asia-Pacific leaders meeting in Beijing marked the first public step to mending the rupture. They had a friendlier meeting in April in Jakarta, and in June their finance ministers held the first formal summit in several years.

“In the summer last year the Chinese government actually changed its strategy toward Japan,” said Yuichi Hosoya, a professor of international politics at Keio University in Tokyo who has served on security advisory panels for Abe. “The Chinese government understood it was impossible to fully separate politics from the economy.”

If a lasting reconciliation is established, the benefit may show in the economy. Trade between China and Japan slumped 6 percent to $343 billion in 2013 and stagnated in 2014. China’s economy meanwhile is growing at its weakest pace in 24 years: expansion slowed to 7.4 percent in 2014.

Japanese investment in China declined nearly 40 percent last year, having fallen since 2012 when Japan’s purchase of three of the East China Sea islets from a private citizen prompted riots in China targeting Japanese businesses.

As part of the attempt to repair the economic damage, Toshihiro Nikai, chairman of the general council of the ruling Liberal Democratic Party, led a 3,000-strong delegation of lawmakers, officials and businesspeople to China in May.

The backdrop to the tensions has been two leaders seeking to fan nationalism at home. Abe is looking to restore Japanese pride. Xi has talked often of China’s “peaceful rise” as a great power that should play a bigger role in global affairs. He has two ambitious “Silk Road” trading routes — one over land, one by sea — to build out via ports, roads and railways to the Middle East and Europe.

He also has tensions in the South China Sea to manage as China asserts its claims in the contested waters, and the potential for a stretched military, given its dispute in the East China Sea. As the heat has risen in the South China Sea it has cooled somewhat farther north, and Japan and China are expected as soon as this month to sign off on a mechanism for maritime and air communication to avoid mishaps.

Domestic politics is giving Xi more room to maneuver on Japan. In the first 18 months of his rule he rebuffed Abe’s calls for a summit as he focused on consolidating power at home.

Xi has now made himself chairman of an unprecedented seven policymaking committees; launched an anti-corruption campaign that reached into the highest levels of the political and military establishment; and unleashed a blizzard of reforms to support the economy and with it the legitimacy of the party.

“You can see from the corruption cases in the Communist Party, Xi is finally in full control of the party and the PLA,” said Keio University’s Hosoya, referring to the People’s Liberation Army. “Xi is extremely pragmatic and fully understands the importance of having a good relationship with Japan, but actually he couldn’t until last November.”

The U.S. has played a role. President Barack Obama in his visit to Japan last year affirmed the U.S. would protect the East China Sea islets. “In 2014 we saw clear signaling from the U.S. showcasing resolve vis-a-vis China,” said Giulio Pugliese, an assistant professor at the University of Heidelberg’s Institute of Chinese Studies.

Still, even if Abe’s August statement avoids fanning controversy, ties are not necessarily on a sustainable longer-term footing.

“Bilateral ties won’t deteriorate more, but wouldn’t improve too much either,” said Su Zhiliang, a history professor at Shanghai Normal University. “The adversarial nature of their positions on the core issues will exist in the long term.”

Jiang Lifeng, a research fellow at the Institute of Japanese Studies at the Chinese Academy of Social Sciences in Beijing, doesn’t expect a major improvement in the relationship.

“China hasn’t made any policy changes, neither has Japan,” he said. “All the exchanges were merely scratching the surface.”