For a while, it looked as though South Korea might abandon a critical military information sharing agreement with Japan. Its last-minute decision to remain in the agreement is welcome news.

Established in 2016, the General Security of Military Information Agreement enables both South Korea and Japan to share military intelligence in partnership with the United States. Both countries benefit immensely, as both face a common threat in nearby North Korea.

In addition to staying in the agreement, South Korea ended its complaint against Japan at the World Trade Organization. Seoul had held that Tokyo’s recent restrictions on exports to South Korea were politically motivated and not compliant with international trade law. Seoul dropped the complaint on Friday.

Both actions will generate domestic criticism of South Korean President Moon Jae-in, since they run against strong anti-Japanese sentiment in the country. Both actions will also likely be seen as resulting from U.S. pressure.

Moon should be commended for putting his country’s national security above popular sentiment. Moon has taken a significant first step back from the precipice amid deteriorating relations with Japan. But his decision is conditional and could be only temporary.

Though denying a package deal, the Japanese trade ministry announced it will hold a bureau-level policy dialogue with Seoul regarding its export controls, the first such meeting in three years.

But Tokyo must go beyond just attending these talks and instead abandon its recently imposed curbs on exports to South Korea. Japan’s justification for the restrictions does not hold water and was clearly a response to last year’s ruling by the South Korean Supreme Court, which ordered Japanese companies to compensate South Koreans who were forced into labor during the Japanese occupation.

The Trump administration deserves credit for influencing Seoul’s decision, albeit belatedly and in a heavy-handed manner. The U.S should have begun more urgent behind-the-scenes diplomacy last year when Seoul withdrew from the 2015 “comfort women” agreement on women forced into wartime sexual slavery, and when the Supreme Court released its decision.

Passions have been enflamed, resulting in strained relations between Seoul, Tokyo, and Washington. This weakens these countries’ ability to respond effectively to regional threats.

It is critical that South Korea and Japan remedy their security and economic relations, and seek to heal the long-standing animosity stemming from the brutal 1910-1945 Japanese occupation of South Korea.

Washington should remain involved, but play a subtler role than it has of late.

The Trump administration should also step back from its insistence on 400%-500% increases in South Korean and Japanese contributions for the cost of stationing U.S. military forces in their countries. Trump’s demand is exorbitant and doesn’t reflect the extensive contributions both countries make in their alliances with the United States.

At a time of growing North Korean and Chinese military threats, the U.S. and its allies cannot afford to be at each other’s throats. Instead, they must stand shoulder to shoulder.