Ecuador has granted asylum to Wikileaks founder Julian Assange two months after he took refuge in its London embassy while fighting extradition from the UK.
It said there were fears Mr Assange’s human rights might be violated.
Foreign minister Ricardo Patino accused the UK of making an “open threat” to enter its embassy to arrest him.
Mr Assange took refuge at the embassy in June to avoid extradition to Sweden, where he faces questioning over assault and rape claims, which he denies.
The Foreign Office said the decision on Mr Assange’s application for political asylum would not affect the UK’s legal obligation to extradite him to Sweden.
It tweeted: “We remain committed to a negotiated solution that allows us to carry out our obligations under the Extradition Act.”
The UK government will still seek to arrest him and it will not grant him safe passage. If he steps out, he will be arrested.
Announcing Ecuador’s decision, Mr Patino said the country believed Mr Assange’s fears of political persecution were “legitimate”.
He said the country was being loyal to its tradition of protecting those who were vulnerable.
“We trust that our friendship with the United Kingdom will remain intact,” he added.
The announcement was watched live by Mr Assange and embassy staff in a link to a press conference from Quito.
Outside Ecuador’s embassy in London, the BBC’s James Robbins said news was slowly spreading through Mr Assange’s assembled supporters and they were delighted.
“The political temperature has risen very significantly. It is clear this is only the beginning of a very long legal contest,” he said.
And BBC legal correspondent Clive Coleman said there was now a “complete standoff” between the UK and Ecuador regarding the status of the embassy in London.
He said the British government now had to make a decision, adding that the risks were enormous – including making other embassies around the world vulnerable.
“I imagine the Foreign Office is awash with lawyers, discussing their options,” said our correspondent.
“I would be very surprised if that power was used – certainly in the short term,” he added.
Mr Assange entered the embassy after the UK’s Supreme Court dismissed the Australian national’s bid to reopen his appeal against extradition and gave him a two-week grace period before extradition proceedings could start.
It was during that fortnight, while on bail, that he sought refuge.
The Wikileaks website Mr Assange founded published a mass of leaked diplomatic cables that embarrassed several governments, particularly the US’s, in 2010.
Earlier, the UK Foreign Office warned it could lift the embassy’s diplomatic status to fulfil a “legal obligation” to extradite the 41-year-old by using the Diplomatic and Consular Premises Act 1987.
That allows the UK to revoke the diplomatic status of an embassy on UK soil, which would potentially allow police to enter the building to arrest Mr Assange for breaching the terms of his bail.
Mr Assange says he fears that if extradited to Sweden, he will then be passed on to the American authorities.
In 2010, two female ex-Wikileaks volunteers accused Mr Assange, an Australian citizen, of committing sexual offences against them while he was in Stockholm to give a lecture.
Mr Assange claims the sex was consensual and the allegations are politically motivated.