SEOUL, South Korea (AP) — South Korea has threatened to end a military intelligence sharing agreement with Japan as a squabble over trade escalates. The breakdown in ties comes as North Korea stages a series of missile tests into the waters between the Korean Peninsula and Japan.

The agreement is supposed to be a symbol of the countries’ security cooperation with their ally, the United States, and it took years of painstaking work to negotiate.

Here’s a look at a military agreement between Seoul and Tokyo that’s being tested by a toxic relationship:

___

THE AGREEMENT

The General Security of Military Information Agreement, or GSOMIA, went into effect in November 2016 as the two neighbors agreed to step up cooperation in the face of North Korea’s nuclear and missile threat.

It is automatically extended annually unless either side notifies the other of its intention to terminate in a 90-day prior notice. The deadline falls on Aug. 24.

The agreement took years of discussion and saw a near-collapse at one point. Any military cooperation with Japan is difficult because of strong resentment against Japanese brutality during its 1910-1945 colonization of the Korean Peninsula.

South Korea and Japan can still share intelligence through the 2014 three-way intelligence pact via Washington, but that one is limited to North Korea’s nuclear and missile program. The agreement allows Seoul and Tokyo to share a broader range of information directly and more quickly.

South Korean military officials say information gathered by Japan’s intelligence satellites, radars, patrol aircraft and other high-tech systems was crucial for analyzing North Korea’s missile tests and its submarines, which could soon be equipped with missile-launch systems. Japan also benefits from South Korean military radars positioned to detect North Korean launches sooner and Seoul’s information from spies and defectors from North Korea.

In 2012, Japan and South Korea backed off from an intelligence-sharing pact less than an hour before a planned signing after Seoul succumbed to a political outcry at home.

___

THE ROW

Tokyo says it wants to keep the agreement despite difficult relations with Seoul.

South Korea says Japan’s trade curbs have forced it to review whether it could continue to send sensitive military information to a country that questions its reliability as a security partner.

Japan said tighter export controls are needed as South Korea’s trade controls are weak, but it earlier linked the export controls to South Korea court rulings ordering Japanese companies to compensate victims of wartime forced labor. Some lawmakers also suggested South Korea may have allowed sensitive materials to reach North Korea.

That enraged many in South Korea, triggering boycotts and protest marches, and lawmakers demanded their government end the intelligence-sharing agreement. Recent surveys indicate more South Koreans were in support of scrapping the agreement.

Japan’s Defense Minister Takeshi Iwaya told reporters on Wednesday that he and visiting U.S. Secretary of Defense Mark Esper agreed on South Korea’s importance in dealing with North Korea.

Esper later traveled to South Korea and met President Moon Jae-in on Friday, and they agreed that the issue over the intelligence-sharing agreement should be “resolved in a good manner,” according to Moon’s office, which didn’t elaborate. It has said Seoul will make a “comprehensive judgment based on national interest” before the Aug. 24 deadline.

Even if South Korea keeps the agreement, threatening to end it might have been a mistake as it would affect long-term trust, said Du Hyeogn Cha, a visiting scholar at Seoul’s Asan Institute for Policy Studies.

“Instead of making a strong request for U.S. mediation based on goodwill, (Seoul) is attempting to hold the United States hostage, saying ‘things can become frustrating for you too’,” said Cha, an ex-intelligence secretary to former South Korean President Lee Myung-bak.

___

THE RISK

A senior Japanese official close to Prime Minister Shinzo Abe, who spoke on condition of anonymity to discuss a sensitive matter, said Japan could probably live without the agreement because it has been used less than expected, and that Tokyo can get information from Washington.

There have been 48 exchanges of military intelligence over the three years since the agreement took effect, with each side contributing information 24 times, South Korean lawmaker Ha Tae-kyung said, citing data he obtained from Seoul’s Defense Ministry. Ha said 19 of Japan’s cases came in 2017, during a provocative run in North Korean weapons tests.

Japan says they communicated about 30 times over the past three years, including only once in 2018 when North Korea’s missile threat subsided.

Some analysts say a scrapped deal would threaten to erase a decade of U.S. effort to link its separate alliances with South Korea and Japan to deal with North Korea and China’s growing influence.

“The South Korea-U.S. alliance will run into trouble,” said Moon Seong Mook, a former South Korean military official and current analyst for Seoul-based Korea Research Institute for National Strategy. “A link for security cooperation between Seoul, Washington and Tokyo will be broken.”

Abandoning the intelligence-sharing agreement with Tokyo could make it harder for each of the two neighbors to respond to actions from China and Russia, including their joint bomber patrol over waters between South Korea and Japan last month, which experts say was likely designed to test security cooperation between the U.S. allies.

Japanese experts, however, see an emboldened South Korea as signaling its shift away from the U.S.-led trilateral cooperation as the U.S. presence in the region wanes.

“South Korea under the Moon administration appears to be not as enthusiastic about the trilateral cooperation with Japan and the U.S. as South Korea used to be in the past,” Junya Nishino, a Korea expert at Keio University, recently said on a TV talk show. “President Moon thinks the current framework is a legacy of the Cold War era and should be changed.”