Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

KUALA LUMPUR — Malaysia put the body of the estranged half-brother of North Korean leader Kim Jong Un on a plane to Pyongyang on Thursday, in a deal that secured the release of its citizens there and ended a drawnout diplomatic spat.

U.S. and South Korean intelligence sources say North Korea masterminded the deadly attack on Kim Jong Nam last month using VX nerve agent, a chemical so toxic that it is on a U.N. list of weapons of mass destruction.

The attack outraged Malaysia and sparked a diplomatic row with North Korea, resulting in travel bans on both sides and a collapse in their long-standing friendly ties.

Malaysian Prime Minister Najib Razak said the nine Malaysians barred from leaving North Korea had been allowed to board a plane out, adding on Twitter that they were expected to reach Kuala Lumpur at 5 a.m. local time on Friday.

The Malaysians left Pyongyang in a Royal Malaysian Air Force business jet, which headed immediately west out of North Korean airspace before turning south toward Malaysia, according to flight tracking website planefinder.net.

"Following the completion of the autopsy on the deceased and receipt of a letter from his family requesting the remains be returned to North Korea, the coroner has approved the release of the body," Najib said in a statement.

The statement did not mention Kim by name. Kim was assassinated at Kuala Lumpur airport on Feb 13.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Earlier, sources told Reuters authorities were preparing to transport Kim's body on Malaysia Airlines flight MH360 to Beijing. That flight lands in Beijing after midnight.

The swap agreement brings to an end nearly seven weeks of diplomatic standoff between the formerly friendly countries.

Najib has said the return of the nine Malaysians in Pyongyang was Malaysia's priority.

North Korea had been demanding the handover of Kim’s body and that three remaining suspects inside its embassy be returned to Pyongyang in exchange for an end to the travel ban on Malaysians, diplomatic sources have said.

It was not immediately clear if the suspects were also allowed to leave Malaysia, although some local media reported that they were taking the same flight to Beijing.

Kim Jong Nam, the eldest son of the late North Korean leader Kim Jong Il, had spoken out publicly against his family's dynastic control of the isolated, nuclear-armed nation.

The young, unpredictable Kim Jong Un had issued a "standing order" for his elder half-brother's assassination, and there was a failed attempt in 2012, according to some South Korean lawmakers.

Malaysian police say Kim was killed by two women who smeared the super toxic nerve agent VX on his face. An Indonesian woman and a Vietnamese woman have been charged.

North Korea reacted angrily when the Malaysian authorities identified North Korean suspects and sought to question others including a diplomat at their embassy in Kuala Lumpur.

Pyongyang has maintained that the body was that of Kim Chol as stated in his passport, and not Kim Jong Nam.

Malaysia expelled North Korea's ambassador for being "diplomatically rude", although Najib later said that ties with Pyongyang would not be severed, in a bid to calm relations.

A statement by the North Korean government released simultaneously said both countries managed to "resolve issues arising from the death of a DPRK national" in Malaysia at a meeting in Kuala Lumpur.

DPRK stands for North Korea's official name, the Democratic People's Republic of Korea.

"The importance of bilateral relations was reaffirmed. In this connection, both countries agreed to positively discuss the re-introduction of the visa-free system and work toward bringing the relations to a higher level," read the statement from North Korea.

Malaysia imposed a travel ban on North Koreans leaving the Southeast Asian country in a tit-for-tat move after Pyongyang barred Malaysians from leaving its borders.

Najib said on Thursday that North Koreans will now be allowed to leave Malaysia.