During a summit in Tokyo with Philippine President Rodrigo Duterte, Prime Minister Shinzo Abe on Monday reaffirmed Tokyo’s commitment to providing economic cooperation worth ¥1 trillion over the next five years.

The move is seen as an economic assistance race against Beijing to form a better relationship with Manila.

Abe has been trying hard to win Duterte over in dealing with territorial disputes in the South China Sea, in which the Philippines is a key diplomatic player.

Meanwhile, China, too, is trying to woo Manila by pledging to extend economic assistance worth $24 billion (¥2.5 trillion). The pledge was made when Chinese President Xi Jinping met with Duterte in Beijing in October last year.

Then, in January, Abe pledged that the government and private-sector corporations will extend economic cooperation worth ¥1 trillion over five years to help Duterte’s initiatives to revamp social infrastructure, including projects to build subways in Manila and improve rivers in Davao City, where Duterte served as mayor for many years.

“The government of Japan will strongly support the sustainable economic development of the Philippines by extending quality infrastructure assistance, using Japan’s funding and technology,” a joint statement issued by the two leaders said.

Japan’s assistance will include programs to ease “serious traffic congestion” in Manila and to “vitalize other areas” as well, it read.

For his part, Duterte has been trying to “maximize” economic assistance both from Japan and China, said Wataru Kusaka, associate professor of political science at the Graduate School of International Development at Nagoya University.

“Duterte’s intention looks very clear. He is trying to maximize what he can win from Japan and China,” Kusaka said.

“So it’s important for Tokyo to have Philippine people feel that Japan is moving fast, in particular in assisting social infrastructure projects. That’s why infrastructure projects come at the top of the list” of economic cooperation items in a summary of a joint statement released by the Japanese government the same day, Kusaka said.

According to the gist, Japan also pledged to help the Philippines introduce better electric and liquefied natural gas facilities to improve the country’s power supply systems.

Tokyo will also help the Philippines crack down on the use of illegal drugs and aid the country in strengthening its maritime safety organization to monitor coastal areas, the statement read.

Duterte arrived in Tokyo on Monday for his second official trip to Japan ahead of the Association of Southeast Asian Nations’ leaders’ summit in Manila next month.

Meanwhile, Abe also tried to use his meeting with Duterte as an opportunity to further step up international pressure on North Korea to abandon its nuclear and missile development programs.

Earlier in the day, Chief Cabinet Secretary Yoshihide Suga said the talks would bea “precious opportunity” for the two nations to “maximize pressure on North Korea.”

At the airport in Manila prior to his departure, Duterte told a group of reporters that dialogue should be prioritized to avoid further intensifying the nuclear crisis.

Duterte has apparently softened his stance since earlier describing North Korean leader Kim Jong Un as a “fool” and a “son of a bitch” who is “playing with dangerous toys.”

In September, following the passage of United Nations Security Council resolutions calling for tougher economic sanctions against the North, Manila suspended trade relations with Pyongyang.

For Duterte, cutting trade ties and emphasizing dialogue with the regime at the same time is not contradictory, said Kusaka of Nagoya University.

Rather, it is part of his signature “balanced diplomacy” of remaining noncommittal to any of the countries, Kusaka said.

“He is trying to tread a fine line of balanced diplomacy with China, the U.S. and Japan,” he said.

Since taking office last year, Duterte has put a fresh emphasis on Japan and China, thereby creating a situation where the two economic powers are “competing” to impress Manila with promises of generous fund infusions.

But at the same time, Duterte, despite his crude rhetoric against Washington, may be viewing the U.S. in a different light after U.S.-led troops intervened to help Manila fight Islamic State-linked militants in what became a five-month-long conflict in Marawi, the associate professor said.

“Aligning the Philippines solely with China is a very risky diplomatic approach to take. This, coupled with the roles the U.S. is said to have played in easing a conflict in Mindanao, has made an alliance with Washington and Japan more and more important for Duterte,” Kusaka said.

Staff writer Tomohiro Osaki contributed to this report.