Japan, South Korea and the United States agreed Wednesday to strengthen their security cooperation over North Korean nuclear and missile threats, according to the Japanese government, as leaders from the countries held the first such trilateral meeting since 2017.

The gathering took place as the change of the South Korean government in May is creating fresh impetus toward improving the soured bilateral ties between Tokyo and Seoul. It also comes amid speculation that Pyongyang's first nuclear test since 2017 could occur at any time.

At the outset of the 23-minute talks on the sidelines of the NATO summit in Madrid, Japanese Prime Minister Fumio Kishida asserted the importance of trilateral cooperation, citing his "deep concerns" over the possibility of further provocation by North Korea, including nuclear testing.

(From R) Japanese Prime Minister Fumio Kishida, U.S. President Joe Biden and South Korean President Yoon Suk Yeol hold talks in Madrid on June 29, 2022. (Pool photo) (Kyodo)

"The deterrence capabilities of the Japan-U.S. and U.S.-South Korea alliances need to be upgraded as part of the essential effort to strengthen the trilateral partnership," he said.

The prime minister also expressed hope that, should a nuclear test take place, the response would be at the trilateral level, including joint exercises.

U.S. President Joe Biden said trilateral cooperation is "essential" to achieve their "shared objective" of complete denuclearization of the Korean Peninsula and a free and open Indo-Pacific, a concept seen as designed to counter China's rising clout.

South Korean President Yoon Suk Yeol said North Korea's provocations should be met with a "powerful response," but the three countries should also cooperate closely so that Pyongyang can return to dialogue toward denuclearization, according to the South Korean government.

The three leaders agreed on the importance of beefing up regional deterrence and pledged to work together to ensure the full implementation of U.N. Security Council resolutions aimed at curbing North Korea's weapons programs, the Japanese government said.

Kishida also secured cooperation from Biden and Yoon toward a resolution of the issue of Japanese nationals abducted by North Korea in the 1970s and 1980s.

North Korea's provocations, including its unprecedented pace of ballistic missile tests this year, have increased the need for trilateral cooperation even as relations between Japan and South Korea remain frosty over issues dating back to Japan's 1910-1945 colonial rule of the Korean Peninsula.

The White House hailed the first such three-way summit since September 2017 as "historic." The three countries also affirmed that they share the same basic values such as freedom, democracy, human rights and rule of law, according to the South Korean government.

Kishida, who took office in October last year, has yet to hold official bilateral talks with Yoon. The trilateral talks on Wednesday reflected the Biden administration's desire to see the relationship between Washington's two closest allies in Asia back on track.

Kishida and Yoon spoke briefly on Tuesday in Madrid in their first face-to-face encounter, both governments said. The two leaders have been invited to the summit of the North Atlantic Treaty Organization as partner countries of the trans-Atlantic alliance.

The last time Japanese and South Korean leaders sat down for talks was in December 2019.

Kishida told reporters on Wednesday before heading back to Japan that he called on Yoon to work to bring the "extremely severe" relationship to a "healthy" state and expressed his willingness to continue communication with the South Korean side.

Yoon's tougher stance toward Pyongyang as compared to his predecessor and his eagerness to forge closer ties with the United States and Japan appear to be helping the three countries align closer in pressuring North Korea.

Earlier in the month, the defense chiefs of Japan, South Korea and the United States agreed to hold trilateral exercises that have not been conducted since December 2017 so as to deal with ballistic missile threats.

South Korean Foreign Minister Park Jin, meanwhile, has said Seoul wants to "normalize" a bilateral military intelligence-sharing pact with Japan known as GSOMIA as soon as possible. The agreement was on the brink of termination during the administration of former South Korean President Moon Jae In.

(Noriyuki Suzuki contributed to this article.)