South Korea has approved a deal to share intelligence on North Korea directly with Japan.
The two countries previously shared their intelligence via the US, but this was seen as a cumbersome process in the face of potentially urgent threats.
They have had tense relations in recent years and the deal is controversial in South Korea, where anger remains over Japanese atrocities in wartime.
The agreement will take effect after it is signed later this week.
It is designed to take advantage of the two countries' perceived intelligence strengths, which in Japan is high-tech surveillance and in South Korea human intelligence, or spies in North Korea.
There were anti-Japan protests outside the presidential palace in Seoul on Monday night, by people who believe Japan has not properly apologised for its treatment of Koreans between 1910 and 1945, when it occupied the peninsula.
Opposition politicians have also suggested the long-delayed agreement was timed to distract from the scandal threatening the South Korean president, although it had been expected to happen soon.
US President Barack Obama has previously indicated his exasperation at the animosity between South Korea and Japan in the face of North Korea's nuclear programme and an increasingly assertive China, says the BBC's Seoul correspondent Steve Evans.