However, Mr Hammond said Mr Assange was a "fugitive from justice", adding that he can come out "any time he chooses" but will still have to face justice in Sweden.

Anders Ronquist, legal chief at Sweden's foreign ministry, said Mr Assange "is not being deprived of his liberty there due to any decision or action taken by the Swedish authorities".

Elisabeth Massi Fritz, lawyer for the alleged rape victim, said the UN panel's decision was "insulting and offensive" to her client and was "against all vulnerable victims' human rights".

Swedish prosecutors dropped an investigation into two sex assault claims against Mr Assange last year after running out of time to question him. However, he still faces the more serious accusation of rape.

Mr Assange fears extradition to Sweden will lead to further extradition to the United States for questioning over the activities of Wikileaks, the website which has published secret documents and videos, including almost 400,000 US military logs.

Mr Assange said the comments by Mr Hammond were "beneath" the minister's stature and "insulting" to the UN, while Ecuador's foreign minister criticised the UK for rejecting the panel's decision.

Ricardo Patiño said the UK had violated "important articles of the Universal Human Rights Convention and of the International Treaty on Political and Civil rights".

The whistleblower Edward Snowden, who is accused of espionage in the US and has received legal support from Wikileaks, tweeted that the UK and Sweden's response to the panel's decision "writes a pass for every dictatorship to reject UN rulings".

In September 2014, Mr Assange complained to the UN that he was being "arbitrarily detained" as he could not leave without being arrested.

The complaint against the UK and Sweden claimed Mr Assange had been deprived of his liberty for an "unacceptable length of time".

The UN's Working Group on Arbitrary Detention insisted Mr Assange's detention "should be brought to an end, that his physical integrity and freedom of movement be respected".

The Wikileaks founder had been subjected to "different forms of deprivation of liberty" it said, initially while he was held in isolation at London's Wandsworth Prison for 10 days in 2010.

The deprivation had been "continuous" since he was initially arrested in the UK on 7 December 2010.

"Mr Assange should be afforded the right to compensation," it added.

'Restricted against will'

Three members of the five-person panel, which has made hundreds of rulings on whether imprisonment or detention is lawful since it was established in 1991, found in Mr Assange's favour.

One rejected his claim and another did not take part in the investigation.

The UK's permanent representative to the UN Julian Braithwaite has written to the panel expressing the government's surprise and disappointment with the outcome.

Responding to criticism of the decision, Christophe Peschoux, from the UN, said: "We can argue on the definition of detention or deprivation of liberty, but the fact is he's restricted against his will and his situation is one of detention since 2010 when he was first arrested."

He said the decision was not a "ruling on the merits of the allegations that have been levelled against Mr Assange" but he said the investigation was still in its "preliminary stage".

"And to the working group's knowledge the investigation has not proceeded and no charge has been filed," he added.

Analysis

Media playback is unsupported on your device

Media captionJulian Assange: Could he be moving on?

By Caroline Hawley, BBC diplomatic correspondent

Julian Assange and his supporters will see this as a significant moral victory.

The Wikileaks founder, who walked into the Ecuadorean Embassy after losing a series of appeals in British courts, now has an important panel of UN legal experts on his side.

Legally binding or not, a UN official said the decision was based on international law.

Although both Britain and Sweden are firmly sticking to their guns, they are now in an extremely awkward position. The Swedish government has seized on the dissenting voice in the panel - who argued, as Britain does, that Mr Assange fled bail and was using the Ecuadorean embassy to evade arrest.

The call for compensation for Mr Assange is particularly controversial when there is already public anger in the UK over the cost of policing his confinement at the embassy.