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.
Swedish prosecutors want to question him over allegations of sexual assault against two women in 2010. He denies the allegations.
Dame Vivienne Westwood paid Mr Assange a visit at the embassy
On Thursday, he had said he would leave the embassy after more than three years if he lost his legal appeal to the UN.
Writing on Twitter, 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."
The ruling is set to be published by the UN body on Friday.
Julian Assange en 2014.
Embajada de Ecuador en Londres, donde Assange permanece asilado.
El Grupo de Trabajo sobre Detención Arbitraria de la  determinó que Julian Assange está detenido de manera arbitraria en la embajada de Ecuador en el Reino Unido. Assange permanece en esa sede diplomática desde 2012, debido a la persecución judicial establecida por el gobierno de Suecia por un caso de presunto abuso sexual por parte del activista.

El fundador de Wikileaks declaró que si el grupo de trabajo de la ONU validaba su detención, de forma inmediata el mismo saldría de la embajada ecuatoriana para entregarse. Pero el fallo del grupo determinó que la detención en efecto es arbitraria y vulnera los derechos fundamentales de Assange. El mismo habría demandado al grupo de la ONU intervenir al decir que la demanda sueca es una represalia por su labor como activista.

En tanto el gobierno del Reino Unido declaró simplemente que independientemente del fallo de la ONU, si Assange coloca un pie fuera de la embajada será inmediatamente detenido. Según Reino Unido la resolución no es legalmente vinculante, aunque Christophe Peschoux, de la oficina del Alto Comisionado de los Derechos Humanos de las Naciones Unidas, si lo es.