The United Kingdom's ambassador to Tehran has returned to Iran after his departure last month following a brief arrest by Iranian security forces, which fuelled speculation that he may not be returning.

"I recently returned from London to Tehran. This was an important trip that was planned some time ago," Rob Macaire said in Farsi in an Instagram video posted on Thursday, noting he met with the UK's foreign minister and other top officials during his trip.

More:

Macaire was briefly detained last month, which Iranian officials said was because he attended an illegal demonstration that took place amid public anger over Iran's belated admission that its military shot down a Ukrainian airliner, killing all 176 on board.

The ambassador said he had attended a vigil for victims of the crash and London claimed his detention was a violation of diplomatic conventions.

Iran's foreign ministry summoned Macaire, who has been in the post since 2018, to complain over the incident and the judiciary labelled him an "undesirable element", state media reported.

A prominent hardline Iranian Muslim leader said at the time that expelling the ambassador would be the best option, and warned that otherwise, loyal supporters of a general killed in a US drone strike in Baghdad last month would "chop him to small pieces".

Tensions in the Middle East escalated In January after the United States killed Iranian military commander Qassem Soleimani, sparking missile attacks by Iran on US bases in Iraq.

Iran said a missile accidentally hit the Ukranian jet.

Friction between Tehran and Washington has been building since 2018 when President Donald Trump withdrew the US from a six-nation nuclear deal in which Tehran agreed to curb its nuclear activities in exchange for the lifting of most sanctions.

View this post on Instagram A post shared by UK in Iran (@ukiniran) onFeb 6, 2020 at 8:12am PST

Iran announced in January that it would abandon limitations on enriching uranium, taking a further step back from the 2015 nuclear deal, but it would continue to cooperate with the UN nuclear watchdog. It says it has never pursued the development of nuclear weapons.

Macaire said in the video that the UK wants to use the dispute resolution mechanism in the multilateral nuclear deal with Iran to find a path forward and that Brexit will not affect its commitment to the deal.

Last month, the UK, France and Germany triggered the deal's dispute mechanism, which amounts to formally accusing Iran of violating the terms of the agreement and could lead to the reimposing of UN sanctions lifted under the deal.

Iran said last month it could quit the global nuclear Non-Proliferation Treaty (NPT) if European countries refer it to the UN Security Council over the nuclear agreement.

The 1968 NPT has been the foundation of global nuclear arms control since the Cold War.