North Korea and Malaysia have banned each other's citizens from leaving their countries, in a growing row over the killing of Kim Jong-nam.
The extraordinary tit-for-tat actions come amid North Korean fury at Malaysia's ongoing investigation into his death at a Kuala Lumpur airport.
The North Korean leader's half-brother was killed with a potent nerve agent.
Malaysia has not directly blamed the North for this, but there is widespread suspicion Pyongyang was responsible.
North Korea has fiercely denied any accusations of culpability and the row over the killing - and who has the right to claim Mr Kim's body - has rapidly escalated over the past two weeks.
Both Malaysia and North Korea have already expelled each other's ambassadors.
North Korean state news agency KCNA said on Tuesday that "all Malaysian nationals in the DPRK [Democratic People's Republic of Korea] will be temporarily prohibited from leaving the country until the incident that happened in Malaysia is properly solved".
It said this was to ensure the safety of its citizens and diplomats in Malaysia.
Malaysians in North Korea would be able to carry on their lives as normal, it added.
Malaysian Prime Minister Najib Razak reacted furiously, describing it as an "abhorrent act ... in total disregard of all international law and diplomatic norms".
Malaysians were effectively being held hostage in North Korea, he said in a statement.
"Protecting our citizens is my first priority, and we will not hesitate to take all measures necessary when they are threatened."
Initially, Deputy Prime Minister Ahmad and Home Minister Zahid Hamidi had said that, in response, North Korean embassy staff and officials would not be allowed to leave.
"We need to take similar steps as they have manipulated the murder," he was quoted as saying.
But Mr Najib later said the ban would extend to all North Koreans.
Numbers affected unclear
Malaysian officials have said there are believed to be 11 Malaysian citizens currently in North Korea, mostly diplomats. They also estimate there are about 1000 North Koreans currently in Malaysia.
The number of North Koreans in Malaysia is unclear, but as well as its diplomatic corps it is known to send citizens there to work as labourers.
Until last week, North Koreans did not need a visa to enter the country.
The measures announced by the two countries are highly unusual. Under Article 13 of the UN Declaration of Human Rights, "everyone has the right to leave any country, including his own, and to return to his country".
Malaysia has signed that declaration, but North Korea has not.
The ban also breaks the Vienna Convention on Diplomatic Relations, which both countries have ratified.
Only two people charged, others still sought
A post-mortem examination of Mr Kim's body found he was killed by a dose of the nerve agent VX, a substance classified as a weapon of mass destruction, as he waited to board a flight to Macau on 13 February.
So far, only two people - an Indonesian woman and a Vietnamese woman - have been charged with murder. They have said they thought they were taking part in a TV prank.
A detained North Korean was released last week because of lack of evidence, but Malaysia is seeking a number of other North Koreans, including a diplomat.
On Tuesday, Malaysia's police chief Khalid Abu Bakar said he believed two of those suspects were hiding inside the North Korean embassy compound in Kuala Lumpur.
"We will wait and if it takes five years we will wait outside, definitely somebody will come out," he told reporters.
Armed police have been deployed outside the embassy, cordoning it off, Malaysian media reported.
- BBC