A diplomatic battle between North Korea and Malaysia following the assassination of Kim Jong Un's half brother escalated sharply Tuesday as the North banned all Malaysians from leaving its territory, prompting the Malaysian government to accuse it of hostage taking.

Malaysia retaliated by banning all North Koreans from exiting its borders and warning the Kim regime that it was inviting further international opprobrium.

“They cannot act at their whims and fancy, violating the international law to hold Malaysians hostage,” Malaysian Prime Minister Najib Razak told reporters in the capital, Kuala Lumpur, on Tuesday before convening an emergency meeting of his national security council. “It is indeed unacceptable not only by Malaysia, but also the world.”

The tit-for-tat moves underscored the sudden breakdown between two nonaligned nations that, until a month ago, enjoyed a pragmatic relationship free from ideological judgments. But the killing of Kim Jong Nam, the estranged older half brother of the North Korean leader, with VX nerve agent in a crowded Kuala Lumpur airport terminal last month has changed all that.

This could result in adverse effects for North Korea, an international pariah that had taken advantage of its visa-free access, now revoked, to conduct a significant amount of business through Malaysia.

“I think this is likely to escalate further,” said Andrea Berger, a North Korea expert with the Middlebury Institute of International Studies. “Malaysia's newfound focus on North Korean activities on its territories could lead it to uncover illicit activities.”

The breakdown in relations with Malaysia will also compound neighboring Singapore's moves last year to make it harder for North Korea to conduct business there. Singapore revoked visa-free access for North Koreans last summer and has also cracked down on transshipments through its ports following new international sanctions imposed in the wake of last year's nuclear and missile tests.

“Together, Singapore and Malaysia had formed a haven for North Korea's illicit activities,” Berger said. “This could have a fusion effect."

Relations between Kuala Lumpur and Pyongyang have deteriorated sharply since the Feb. 13 assassination of Kim Jong Nam. North Korean diplomats strongly objected to Malaysia's insistence on carrying out an autopsy on the body and denounced the finding that he was killed with a weapon of mass destruction. Malaysia has refused to release the body without DNA identification from next of kin, and no family member has come forward to provide the match and claim the body.

North Korean diplomats insisted that the man, whom they have not identified as being the leader's half brother, died of a heart attack. The North’s ambassador to Malaysia, Kang Chol, accused Najib's government of conspiring with South Korea to make Pyongyang look bad.

Malaysia responded by expelling the ambassador. He left Monday evening, flying in a middle seat in economy class on a Malaysia Airlines flight to Beijing after having checked in a Philips TV. North Korea consequently said it would expel Malaysia's ambassador, although he had already returned to Kuala Lumpur for consultations soon after the attack.

But the standoff escalated suddenly Tuesday when North Korea announced that Malaysian citizens were “temporarily” barred from leaving the country.

The Foreign Ministry in Pyongyang informed the Malaysian Embassy that they could not leave “until the safety of the diplomats and citizens of [North Korea] in Malaysia is fully guaranteed through the fair settlement of the case that occurred in Malaysia,” the ministry said in a statement carried by the state-run Korean Central News Agency. The statement did not say what North Korea would consider a “fair settlement.”

Eleven Malaysians are known to be in Pyongyang: three embassy staff, six family members and two others who work for the United Nations’ World Food Program.

Malaysian officials said they were safe. “There is no threat to their lives. Let us not come to that point yet,” said Reezal Merican, the deputy foreign minister.

Najib, the prime minister, denounced the move as an “abhorrent act” and said he had instructed authorities to prohibit all North Koreans from leaving Malaysia — not just diplomats, as some of his officials had previously stated — while Pyongyang was “effectively holding our citizens hostage.”

Malaysian police surrounded the North Korean Embassy in Kuala Lumpur with tape and armed officers Tuesday.

The Malaysians have accused three North Koreans still in Malaysia of involvement in the plot to attack Kim Jong Nam. They include a diplomat and an employee of the North Korean state airline, both believed to be hiding out in the embassy. Malaysia’s police chief suggested he would be willing to wait “five years” for them to come out.

Hundreds of other North Korean citizens remain in Malaysia. Because North Koreans were able to travel to Malaysia visa-free, the country had been a popular destination for North Koreans involved in trade and business. About 170 North Koreans are also believed to be working in mining and construction in the Sarawak region, sent there by the regime as part of its efforts to earn hard currency through labor exports.

North Korea and Malaysia had enjoyed friendly relations for more than four decades, opening embassies in each other’s capitals in 2003 and allowing each other’s citizens to travel visa-free — a privilege that North Korea does not enjoy even with neighboring China.

In 2013, Help University in Kuala Lumpur conferred an honorary doctorate in economics on Kim Jong Un. And just three days before the attack on Kim Jong Nam, North Korea and Malaysia signed an agreement to promote links in “culture, arts and heritage,” according to NK News, a specialist website.

But there have also been widespread suspicions that North Korea was taking advantage of its access to Malaysia to skirt U.N. sanctions. North Korean intelligence agents had been running a front company called Glocom out of Kuala Lumpur, offering to sell radio systems for “military and paramilitary” organizations, Reuters news agency reported last week.