South Korea decided Friday against scrapping a critical military intelligence-sharing pact with Japan, in a dramatic 11th-hour U-turn that will come as a relief to the United States.
The pact was due to expire at midnight amid a sharp deterioration in ties between the two democracies and market economies that has alarmed Washington as it seeks to curb the threat from nuclear-armed North Korea.
But after a flurry of last-ditch diplomacy, Seoul announced it would "conditionally" suspend the expiry of the agreement with just six hours left on the clock.
Kim You-geun, a national security official at Seoul's presidential Blue House, confirmed the accord, known as GSOMIA, would not be allowed to lapse at midnight.
"The Japanese government has expressed their understanding," he said.
He warned, however, that the pact could still "be terminated at any time".
Japan's Prime Minister Shinzo Abe said three-way co-ordination between Tokyo, Seoul and Washington was "extremely important," adding that he believed South Korea had taken their decision from a "strategic point of view."
But Defence Minister Taro Kono stressed that it was a temporary measure and urged Seoul to extend the pact "in a firm manner."
Officials are now scrambling to arrange bilateral talks between Japanese Foreign Minister Toshimitsu Motegi and South Korean counterpart Kang Kyung-wha on the sidelines of a meeting of G20 foreign ministers in Nagoya.
Seoul had announced the scrapping of the pact in August, as a trade row sparked by historical disputes between the pair spiralled into one of their worst diplomatic spats in years.
Seoul and Tokyo are both major US allies seen as an anchor of stability in a tinderbox region with overbearing China and wayward, nuclear-armed North Korea.
But their relationship is heavily coloured by territorial and historical disputes stemming from Japan's bitterly-resented 35-year colonial rule over the peninsula, including the use of wartime sex slaves and forced labour.
The GSOMIA pact, signed in 2016, enabled the two US allies to share military secrets, particularly over Pyongyang's nuclear and missile capacity.
The United States had frequently urged its two main allies in the region to bury the hatchet, with officials admitting privately that the poor relations are complicating diplomacy in the region.
Ditching the pact would have been "a huge setback for one of the pillars of East Asia's security that Japan, South Korea and the United States have established", said Kenichiro Sasae, a former top Japanese foreign minister official and ambassador to the US.
Defense Secretary Mark Esper said on a recent trip to Asia that the only beneficiaries from the pact being scrapped would be North Korea and China, and urged the two allies to "sit down and work through their differences".
South Korea had promised to continue sharing secrets via the United States as a third party, but this had raised concerns about efficiency in an emergency situation.
Seoul had renewed the pact every year and its sudden decision to scrap it had come as a surprise as most thought the country would maintain security cooperation with Japan despite the ongoing row.
However, ties between the pair remain in the deep freeze after a string of South Korean court rulings ordering Japanese firms to compensate wartime forced labour victims infuriated Japan.
Relations were further hit in July after Tokyo said Seoul was not properly handling sensitive imports and took the country off a list of nations that enjoyed streamlined export control procedures.
This enraged South Korea, which hit back with similar moves, culminating in the decision to end the military pact.
Japan says a 1965 treaty that normalised relations with a significant financial contribution effectively settled all reparation claims from its wartime atrocities. "The biggest issue and the root problem is the issue related to former labourers from the Korean peninsula," Motegi told reporters.
"We continue to strongly demand South Korea to remedy as soon as possible the current situation that violates the international law."
On the trade issue, Japanese trade ministry official Yoichi Iida said the two countries would hold talks "as soon as possible" to resolve their row but insisted this had "nothing to do" with the military pact.