Japanese Prime Minister Fumio Kishida and South Korean President Yoon Suk Yeol spoke briefly Tuesday in Madrid, both governments said, in their first face-to-face encounter amid chilly ties over wartime issues.

The conversation took place on the fringes of a summit of the North Atlantic Treaty Organization that the two leaders are attending, keeping hopes alive for a thaw in bilateral relations under Yoon, who became president in May with a pledge to take a "future-oriented" approach.

Kishida told Yoon during a dinner hosted by King Felipe VI of Spain that he hopes the South Korean president will work to restore the countries' "extremely severe" relations to "a healthy state," the Japanese Foreign Ministry said.

South Korea's presidential office said the conversation lasted three to four minutes and quoted Yoon as telling Kishida that he intends to resolve pending issues of concern to both nations swiftly after Japan's upper house election and move forward in a future-oriented manner.

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

The latest encounter came at a delicate time for Kishida ahead of the House of Councillors election on July 10.

He needs the support of the ruling Liberal Democratic Party's conservative base, which believes the government should take a firm stance amid disputes over compensation related to Japan's 1910-1945 colonial rule of the Korean Peninsula that continue to cast a deep shadow over ties between the U.S. allies.

Bilateral ties worsened during the administration of Yoon's predecessor Moon Jae In after the South Korean Supreme Court in 2018 ordered two Japanese companies to pay damages to Korean plaintiffs over their forced labor.

The companies did not comply with the orders, based on Tokyo's stance that wartime compensation issues were settled by a 1965 bilateral agreement under which Japan provided grants and loans to South Korea.

Prior to the NATO summit, reports emerged that the South Korean government is preparing a public-private body for officials and experts to explore how to resolve wartime labor issues.

Another dispute over the issue of "comfort women," procured for Japan's wartime military brothels, has also hurt diplomatic ties, as Tokyo continues to urge Seoul to follow through on a 2015 accord that settled the issue "finally and irreversibly."

The fraying of ties comes as bilateral and trilateral cooperation with their shared ally the United States has taken on greater importance to counter the North Korean missile and nuclear threats.

The brief conversation came as Japan and South Korea examine how to cope with an assertive China just as NATO also reviews its own approach. Kishida and Yoon were invited to attend the NATO summit as their nations are NATO partners.

In March, Kishida spoke by phone with Yoon soon after the conservative main opposition party candidate won the presidential election and expressed his hope of holding an in-person meeting.