SEOUL, South Korea (AP) — South Korea said Thursday it will terminate an intelligence-sharing deal with Japan that focused on classified information about North Korea, a surprise announcement that is likely to set back U.S. efforts to bolster security cooperation with two of its most important allies in the Asian region.

South Korea attributed the decision to its bitter trade dispute with Japan, which has plunged the two countries’ relations to their lowest point since they established diplomatic ties in 1965. Japanese Foreign Minister Taro Kono called the decision “extremely regrettable” and summoned the South Korean ambassador to protest the linking of trade and security issues.

Many experts had predicted that South Korea would be unlikely to spike the 3-year-old intelligence-sharing deal for the sake of its relations with the United States. South Korea has been seeking U.S. help in resolving the trade dispute, and Seoul and Washington have also been working together to restart stalled talks on stripping North Korea of its nuclear weapons.

South Korea’s presidential office said it terminated the intelligence deal because Japan’s recent decision to downgrade South Korea’s trade status caused a “grave” change in security cooperation between the countries.

“Under this situation, the government has determined that maintaining the agreement, which was signed for the purpose of exchanging sensitive military intelligence on security, does not serve our national interests,” Kim You-geun, the deputy director of South Korea’s presidential national security office, said in a nationally televised statement.

He said South Korea would formally notify Japan of its decision before Saturday, the deadline for an extension of the pact for another year.

Japanese Foreign Minister Kono said in a statement that the decision “was an action that completely misjudged the current security environment in the region and is extremely regrettable.”

He said South Korea’s linking of trade and security was “absolutely unacceptable, and we firmly protest to the South Korean government.”

Since early last month, Japan has imposed stricter controls on exports to South Korea of three chemicals essential for manufacturing semiconductors and display screens — key export items for South Korea — and decided to remove South Korea from a list of countries granted preferential trade status.

South Korea accuses Japan of weaponizing trade to punish it over a separate dispute linked to Japan’s brutal colonial rule of the Korean Peninsula from 1910 to 1945. Japan denies that, saying its steps were taken because of unspecified security concerns.

The Japanese trade curbs triggered an outburst of anti-Japan sentiment in South Korea. Many South Korean citizens rallied in the streets, canceled planned holiday trips to Japan and launched widespread boycotts of Japanese beer, clothes and other products. The South Korean government, for its part, decided to downgrade Japan’s trade status.

Some experts say the tit-for-tat actions could eventually hurt South Korea’s economy more than Tokyo’s. Many big South Korean manufacturers including Samsung rely heavily on materials and components imported from Japan, while Japan doesn’t import many vital materials from South Korea.

Liberal South Korean President Moon Jae-in, who earlier declared his country would “never again lose” to Japan, used the Aug. 15 anniversary of Korea’s liberation from Japan to extend an olive branch. Moon said Seoul will “gladly join hands” if Tokyo wanted to talk.

There was no immediate reaction from the U.S. government. On Wednesday, the top U.S. envoy on North Korea, Stephen Biegun, told reporters in Seoul that he appreciated what he called “strong and continued cooperation between the U.S., South Korea and Japan.”

The intelligence deal went into effect in 2016, reportedly at the strong urging of the United States, which wants to boost three-day security cooperation to better cope with North Korea’s nuclear threat and a rising China. The United States stations a total of 80,000 troops in the two Asian countries, the core of America’s military presence in the Asia-Pacific region.

Experts said the deal enabled a quicker exchange of information between Seoul and Tokyo, because they had previously exchanged intelligence via the United States. In 2012, the countries nearly forged a similar deal but it was scrapped at the last minute following a vehement backlash in South Korea.

However, it is unclear how effective the deal has been for both countries, especially on intelligence on North Korea, one of the world’s most secretive countries. But there has been a general consensus that South Korea needed information gathered by Japanese satellites and other high-tech systems, while Japan enjoyed signal, voice and human intelligence from South Korea.

South Korea’s Defense Ministry said in a statement Thursday that it will try to maintain a “stable and perfect combined security posture” with the United States regardless of the termination of the intelligence deal. It called the South Korean-U.S. alliance “powerful.”

South Korean government and ruling party officials have publicly questioned how Seoul could share intelligence with a country that questioned Seoul’s handling of sensitive materials imported from Japan. Without providing concrete evidence, some Japanese officials including Prime Minister Shinzo Abe have suggested that some critical Japanese materials with potential military applications exported to South Korea may have reached North Korea. Seoul flatly denies that.

READ MORE: What’s behind South Korea-Japan trade tensions

The fate of the deal had divided people in South Korea. Some argued that South Korea should do whatever it could to inflict pain on Japan, and that just floating the idea of ending the intelligence deal could force the United States to persuade Japan to lift its trade curbs. But some stressed that the deal’s cancellation would impair relations with the United States at a time when South Korea faces many security challenges including the stalemated North Korean nuclear talks.

Moon’s government has lobbied hard to facilitate talks between the U.S. and North Korea on the nuclear crisis. But the diplomacy has remained largely stalemated for months, and North Korea now says it won’t go through South Korea to talk to the United States. The North recently test-fired a series of short-range missiles and other weapons capable of striking much of South Korea.

Last month, a Russian military plane allegedly violated South Korean airspace in the first such trespassing by a foreign warplane since the end of the 1950-53 Korean War. Russian and Chinese warplanes allegedly also made a highly unusual joint entrance to South Korea’s air defense identification zone, in what analysts said was an attempt to see how the Seoul-Washington-Tokyo security cooperation worked.

South Korea’s main conservative opposition party accused the Moon government of confusing “genuine courage” with “foolhardy courage.” The Liberty Korea Party said security coordination with Washington and Japan needed to be solidified in the face of strengthening cooperation among Russia, China and North Korea.

“We would have lots of things to lose from the deal’s termination,” said analyst Go Myong-Hyun of the Seoul-based Asan Institute for Policy Studies. “If the U.S. turned its back on South Korea, we would be completely isolated in Northeast Asia.”

On Thursday evening, about 30 anti-Tokyo activists gathered near the Japanese Embassy in Seoul to welcome the intelligence deal’s termination. Jubilant participants held placards that read “The scrapping of the South Korea-Japan deal is a people’s victory.”

Associated Press journalists Lee Jin-man in Seoul, South Korea, and Mari Yamaguchi and Yuri Kageyama in Tokyo contributed to this report.