Sweden’s foreign ministry has said a UN report concludes that Julian Assange has been “arbitrarily detained” in a London embassy.

Ministry spokeswoman Katarina Byrenius Roslund said: “Their working group has made the judgement that Assange has been arbitrarily detained in contravention of international commitments.”

The WikiLeaks founder, 44, has been holed up in the Ecuadorian Embassy in west London since June 2012 and has been granted political asylum by the Ecuador government.

A lawyer for the 44-year-old told Associated Press news agency that if the UN panel rules he has been arbitrarily detained, then Sweden has no other option but to revoke an arrest warrant which could allow him to walk free from the embassy.

Swedish prosecutors want to question him over allegations of sexual assault against two women in 2010. He denies the allegations.

On Thursday, he had said he would leave the embassy after more than three years if he lost his legal appeal to the UN.

In a statement, he said: “(But) should I prevail and the state parties be found to have acted unlawfully, I expect the immediate return of my passport and the termination of further attempts to arrest me.”

The Australian had filed a complaint against Sweden and the UK in September 2014, which was being considered by the UN Working Group on Arbitrary Detention.

Mr Assange claims if he went to Sweden he could be handed over to US authorities for prosecution over the disclosure of classified military and diplomatic documents by WikiLeaks in 2010.

In the UN submission, he argued that he is the victom of a witch hunt directed by the US and his fate is a test case for freedom of expression.

He also argued that he had been deprived of his fundamental liberties while staying in the embassy, including a lack of access to sunlight or fresh air, adequate medical facilities and has been subjected to legal and procedural insecurity.

Vaughan Smith, a friend of Mr Assange, said he was “delighted” by the UN decision.

He told Sky News: “He has appealed to the highest authority available to him and they have come out in his favour completely, and I’m delighted that the Swedish government have recognised this and hopefully they’ll drop the case and Julian will be able to go to Ecuador or wherever he likes.

“We have failed shamefully in our human rights, in our treatment of this person. I think to disregard that sends a terrible message.

“How are we going to hold our head high as a country that considers itself to be full of fair and decent people if we’re not prepared to respect rafts of human rights legislation.”

Britain has said Mr Assange would be arrested if he leaves the embassy and then extradited to Sweden.

A British government spokeswoman said: “We have been consistently clear that Mr Assange has never been arbitrarily detained by the UK but is, in fact, voluntarily avoiding lawful arrest by choosing to remain in the Ecuadorian embassy.

“An allegation of rape is still outstanding and a European Arrest Warrant in place, so the UK continues to have a legal obligation to extradite Mr Assange to Sweden.”