Image copyright Getty Images Image caption Kim Jong-Un (c)

A bitter stand-off between Malaysia and North Korea appears at an end after the two countries revoked a travel ban which had effectively kept their respective citizens hostages for more than three weeks. But has North Korea come out on top?

The diplomatic row was sparked by the killing of Kim Jong-nam, the half-brother of North Korean leader Kim Jong-un.

According to Malaysia, Kim died as the result of exposure to a VX chemical weapons agent in a plot widely believed to have been orchestrated by as many seven North Koreans and assisted - whether wittingly or not - by two Asian women currently in custody.

While Malaysia has not officially accused North Korea of responsibility for the killing, their investigation has involved an autopsy of Kim's body and an attempt to question the suspected North Korean plotters. They also presented a report documenting the use of chemical weapons to the Organization for the Prohibition of Chemical Weapons.

Pyongyang rejected any suggestion that it was behind the killing while publicly asserting that the dead individual was not the half-brother of the North Korean leader, but rather an entirely different individual.

Confronted by North Korea's unwillingness to allow its staff to be questioned, Malaysia refused to hand over Kim's body and the North retaliated by refusing to allow Malaysians to leave the North.

As a result of Thursday's agreement, several North Korean suspects, reportedly together with Kim's body, were allowed to travel on Friday to North Korea and, in return, nine Malaysians were also permitted to travel home.

Image copyright AFP Image caption There were emotional reunions in Kuala Lumpur airport as Malaysians citizens returned home from North Korea

While a welcome outcome for the Malaysian detainees, the government of Malaysian Prime Minister Najib Razak appears to have capitulated to the North's coercive tactics - not the first time Pyongyang has used detention as a means of exerting diplomatic leverage.

However, the background to the agreement is murky and it is possible that the Malaysian government, which apparently succeeded in questioning the North Korean suspects before they returned home, may have had its own leverage to employ against the North.

How was their relationship before the murder?

Diplomatic relations date from 1973 and the two countries have commercial ties.

They totalled $4m (£3.1m) in 2016 - modest but still significant for a country such as North Korea which has relatively limited foreign trade.

Image copyright Getty Images Image caption Malaysian Prime Minister Najib Razak engaged in a tit-for-tat row with North Korea after the murder

North Korea imports rubber, palm oil and refined oil from Malaysia, and there are hundreds of North Koreans working in the mining and restaurant sectors in Malaysia.

Keen to promote tourism, North Korea had also introduced a visa-free travel arrangement with Malaysia - which was suspended as a result of the latest row.

More importantly, Malaysia has long been a key site for illegal arms component acquisition and weapons trading by North Koreans operating through a number of front companies.

A UN report has highlighted some of these activities and while the Malaysian authorities have yet to provide a formal response, their recent decision to delist two of the firms allegedly involved is an indication that the benefits for the North Koreans of the Malaysian relationship in terms of facilitating their covert commercial activity and evading international sanctions may be at risk.

Whether Malaysia would have used the potential loss of this cover as a negotiating gambit is unclear.

Where do they go from here?

For now, Prime Minister Najib's recent public remarks expressing his hope that a "case like this" doesn't happen again, suggests that diplomatic ties, while frayed, will continue but with Pyongyang effectively on probation.

To the wider world, the powerful evidence that North Korea continues to flout international norms, whether through state-sanctioned executions or forced detentions, is a sobering reminder of the challenge of engaging constructively with Pyongyang.

Image copyright Getty Images Image caption Footage of a North Korean missile test was broadcast on a big screen in Pyongyang in March

Such bad behaviour, when set alongside the North's nuclear and missile tests, as well as its increased ability to threaten its neighbours, suggests that conscious, premeditated provocation, rather than impulsiveness, may be part of the intentional strategy of Kim Jong-un.

Instead of labelling him as "not a rational actor", which is what US ambassador to the UN Nikki Haley did, or a "crazy fat kid", in the words of Senator John McCain, the world might be better advised to recognise Kim Jong-un's success in single-mindedly pursuing his own interests.

By not playing by the rules, Pyongyang has been, to date, strikingly successful in getting what it wants.

The challenge for the international community is finding an effectively coordinated means of responding to these provocations, without appearing to give in to diplomatic blackmail.