Image copyright European Photopress Agency Image caption Among those who have returned include Malaysia's counsellor to North Korea, Mohd Nor Azrin Md Zain (centre)

Nine Malaysians who were prevented from leaving North Korea have arrived home, after the two countries struck a deal to end a diplomatic row.

The quarrel, over last month's killing of Kim Jong-nam in Kuala Lumpur, had resulted in both countries banning each other's citizens from leaving.

Two North Koreans wanted for questioning are believed to have been allowed to leave Malaysia.

Malaysia has also released Mr Kim's body to Pyongyang.

North Korea is widely suspected to have orchestrated Mr Kim's murder.

Mr Kim was the half-brother of North Korean leader Kim Jong-un. The late Kim Jong-il's eldest son was passed over for the leadership and was living outside North Korea at the time of his death.

The nine Malaysian nationals were met by their relatives and a large media contingent at Kuala Lumpur airport early on Friday.

Image copyright European Photopress Agency Image caption Malaysia's foreign minister Anifan Aman (centre, in dark pink coat) received the returning Malaysians at Kuala Lumpur's airport

Those who have returned include the country's counsellor to North Korea, Mohd Nor Azrin Md Zain, embassy staff and their families.

The counsellor said that when Pyongyang told them they could not leave North Korea, "we were very concerned especially since we had committed no wrong".

But he added they were "not particularly harassed" by North Korean authorities. "We were given the assurance that life could go on as normal," he said.

They were flown home in a business jet plane piloted by members of the Malaysian air force.

What was the spat about?

Following Mr Kim's killing on 13 February, North Korean officials demanded that his body be handed to them immediately without an autopsy.

Pyongyang reacted angrily when Malaysia refused their requests.

Malaysian authorities said they had the right to conduct an autopsy as he had been killed on Malaysian soil, and said they would only release the body to Mr Kim's family.

Image copyright AP Image caption Mr Kim was the half-brother of North Korean leader Kim Jong-un

This prompted a war of words where North Korea's ambassador Kang Chol accused Malaysia of colluding with "hostile forces", allegations which Kuala Lumpur dubbed as "delusions, lies and half-truths".

Kang Chol was expelled and the Malaysian ambassador to North Korea was also recalled.

Pyongyang then said it would ban all Malaysians in North Korea from leaving until the "situation was resolved", which Malaysia's Prime Minister Najib Razak called an "abhorrent act" that effectively held his citizens hostage.

Kuala Lumpur enacted a tit-for-tat exit ban on North Koreans.

How was it resolved?

Malaysian officials have not hesitated in branding the return of their citizens as a triumph of diplomatic deal-making.

On Friday morning Malaysian Foreign Minister Anifah Aman told reporters: "There can be no substitute for diplomacy, for level-headedness in dealing with such situations, and this has served Malaysia well in this instance."

But the exact circumstances of how the deal was struck remain unclear. Correspondents say that Malaysia appears to have acceded to North Korea's wishes to get the Malaysians released.

Mr Najib had said earlier that, after challenging negotiations, all North Koreans would be allowed to leave Malaysia - which probably includes those wanted by Malaysian police for questioning.

Japanese news agency Kyodo said two men resembling two wanted North Koreans were seen on a Beijing-bound flight transporting Mr Kim's body on Friday.

Image copyright Kyodo/Reuters Image caption One man on the plane (left, in white) resembles Kim Uk Il, according to Kyodo

The men are thought to be Hyon Kwang Song, the second secretary at the North Korean embassy in Kuala Lumpur, and Kim Uk Il, an employee of North Korea's state airline Air Koryo.

The two men were previously reported to have been holed up in the embassy and refused to take part in investigations.

Malaysian Insight quoted Attorney-General Mohamed Apandi Ali as saying that authorities allowed two North Korean diplomats to leave "to secure the safe release" of the Malaysians. He did not name the diplomats.

He told the news portal that they were not suspects in Mr Kim's murder and were only needed to "assist in investigations".

What's happened to the body?

Mr Kim's body was released to North Korea and flown to Beijing, where North Korean officials are expected to receive it.

Image copyright AFP/Getty Images Image caption North Korean and Chinese officials were seen at Beijing airport after the plane carrying Mr Kim's body landed early on Friday

Malaysia had previously said they would not release the body until a request came from family members.

On Thursday, Mr Najib said a formal request had been received from the family, but did not give further details.

Mr Kim's own family previously lived in Macau but they are now thought to be in hiding.

His son Kim Han-sol appeared in a video earlier this month confirming he was with his mother and sister at an unspecified location.

A delicate task - Jonathan Head, BBC News, South East Asia correspondent

It was with barely disguised relief that Malaysian Prime Minister Najib Razak announced the deal with North Korea to release Kim Jong-nam's body, after what he described as "sensitive" negotiations posing many challenges.

Dealing with a regime that, in Malaysia's view, was holding its citizens hostage and had carried out a lethal chemical weapons attack inside its main international gateway was a delicate task.

Malaysia appears to have given North Korea what it wanted - the body and the North Korean suspects sought by the Malaysian police - in order to get its nine citizens back safely.

To that end, North Korea has refused to recognise that the body was that of its supreme leader's half-brother, or to cooperate in clarifying the role of its agents in the attack.

But by permitting a letter from an as-yet unnamed family member in North Korea to be forwarded to Malaysia, authorising the body's release, there is at least tacit acknowledgement from Pyongyang that the body is indeed Kim Jong-nam - something the Malaysian authorities say they have already confirmed through DNA samples obtained from his relatives outside North Korea.

But with all the North Korean suspects in the attack now apparently out of Malaysia it is not clear how the investigation can move forward.

The two women, an Indonesian and a Vietnamese, who smeared the nerve agent on Kim Jong-nam's face are in custody facing murder charges, but we do not know how much they have been able to tell the Malaysians.

Nor do we know how much the Malaysian authorities have learned about that nerve agent.

They believe it is VX, a substance so dangerous it is classified as a weapon of mass destruction, but it is not clear how much they have consulted with allies, or shared their findings with the international organisations that monitor chemical and biological weapons.