SEOUL/NAGOYA, Japan (Reuters) - South Korea on Friday made a last-minute decision to stick with its critical intelligence-sharing deal with Japan, a dramatic reversal after months of frigid relations complicated by painful, wartime history.

FILE PHOTO: A police officer stands guard near Japan and South Korea national flags at a hotel, where the South Korean embassy in Japan is holding the reception to mark the 50th anniversary of the normalisation of ties between Seoul and Tokyo, in Tokyo June 22, 2015. REUTERS/Toru Hanai/File Photo

The decision, announced by South Korea’s presidential Blue House, was welcomed by Washington. The United States has pressured its two Asian allies to set aside their feud and maintain the General Security of Military Information Agreement (GSOMIA), seen as linchpin of trilateral security cooperation.

“This decision sends a positive message that like-minded allies can work through bilateral disputes,” a spokeswoman for the U.S. State Department said.

“We encourage (South Korea) and Japan to continue sincere discussions to ensure a lasting solution to historic issues,” she said, adding that Washington strongly believed that defense and security issues should be kept separate from other areas of their relationship.

The diplomatic thaw also has implications for trade. As the rift worsened this year, Japan put export curbs on materials used to make semiconductors, threatening the global supply chain of chips, a pillar of the South Korean economy.

Seoul decided to suspend a previous notice to Japan that it would stop sharing intelligence once the current pact ran out at midnight on Friday, Kim You-geun, deputy director of South Korea’s national security office said, adding it had done so on the condition the agreement could be terminated at any time.

“Japan has expressed its understanding,” Kim told a briefing just hours before the deal was due to end.

Japanese Prime Minister Shinzo Abe said South Korea had made a “strategic decision” in sticking with the pact and that bilateral relations were vital.

News of the decision quickly grabbed the limelight at the Group of 20 (G20) foreign minister meetings being held in the central Japanese city of Nagoya.

In almost unheard of move, Japanese Foreign Minister Toshimitsu Motegi briefly stepped out of a bilateral meeting with his Russian counterpart to address reporters.

“My understanding is that the South Korean government took this strategic decision, given the current security environment,” Motegi said, adding he would meet the South Korean foreign minister during the G20.

South Korea’s foreign minister, Kang Kyung-wha, had been notable for her absence at the G20. Her attendance had not been formally confirmed and she only arrived in Nagoya late on Friday, after the decision had been announced.

As the news broke, Japanese reporters stepped away from their laptops in the G20 media center to huddle around a television.

‘WHITE LIST’

The dispute has its roots in a decades-old disagreement over compensation for South Korean laborers forced to work at Japanese firms during World War Two. It has deepened this year, and upended trade between the two countries.

South Korea was the third-largest market for Japanese exports last year, accounting for $53 billion, according to IMF data. Japan remains a major player in specialized chip components, even though it was overtaken as a chipmaker years ago by South Korea.

Japan’s trade ministry said it hoped to hold talks with South Korea on export controls but it would not immediately put Seoul back on the trade “white list” that fast-tracks exports to its neighbor.

Japan’s trade ministry had been the setting for a particularly frosty meeting between officials from both sides earlier this year, where neither side greeted the other and, in front of television cameras, faced off in stony silence in a narrow room.

South Korean media widely reported that their officials had been given a “cold reception” by Tokyo and that the meeting took place in a room that looked like a “garage”.

Motegi denied that the United States had put pressure on Tokyo over GSOMIA, which was sealed in 2016 after a years-long U.S. push for a better joint response to North Korea’s growing military threat, but acknowledged close communication with Washington on the matter.

U.S. TENSION

A South Korean official said on Friday there was no deadline set yet to resolve the differences, and Seoul would terminate the pact if agreement was not reached.

Seoul’s decision has also come amid increasingly public displays of tension with the United States, rare in the nearly seven decades of their alliance.

The United States broke off defense cost talks this week after demanding that South Korea raise its annual contribution for maintaining the U.S. contingent to $5 billion, more than five times what it pays now.

U.S. President Donald Trump has railed against what he says are inadequate contributions from allies towards defense costs. Washington is due to begin separate negotiations for new defense cost-sharing deals with Japan, Germany and NATO next year.