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 may be violated.
Foreign minister Ricardo Patino accused the UK of making an "open threat" to enter its embassy to arrest Mr Assange.
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.
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 are vulnerable.
"We trust that our friendship with the United Kingdom will remain intact," he added.
Outside Ecuador's embassy in London, the BBC's James Robbins said news was slowly spreading through Mr Assange's assembled supporters.
Our correspondent said they were delighted, but the UK government is insisting it changes nothing.
They will still seek to arrest him and they will not grant him safe passage. If he steps out, he will be arrested.
Mr Assange entered the embassy after the UK's Supreme Court dismissed Mr Assange'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.
A subsequent offer by Ecuador to allow Swedish investigators to interview Mr Assange inside the embassy was rejected.
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.
Stay informed. Subscribe to our newsletter
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.
BBC