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 his human rights might be violated if he is sent to Sweden to be questioned over sex assault claims.
Foreign Secretary William Hague said the UK would not allow Mr Assange safe passage out of the country and the move was also criticised by Stockholm.
Ecuador said it would seek to negotiate arrangements for Mr Assange to leave.
"We don't think it is reasonable that, after a sovereign government has made the decision of granting political asylum, a citizen is forced to live in an embassy for a long period," Foreign Minister Ricardo Patino said.
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.
Mr Patino had accused the UK of making an "open threat" to enter its embassy to arrest Mr Assange, an Australian national.
Mr Assange said being granted political asylum by Ecuador was a "significant victory" and thanked staff in the Ecuadorean embassy in London.
However, as the Foreign Office insisted the decision would not affect the UK's legal obligation to extradite him to Sweden, Mr Assange warned: "Things will get more stressful now."
"It was not Britain or my home country, Australia, that stood up to protect me from persecution, but a courageous, independent Latin American nation," said Mr Assange, who watched the announcement with embassy staff in a live link to a press conference in Quito.
"While today is a historic victory, our struggles have just begun. The unprecedented US investigation against Wikileaks must be stopped.
"While today much of the focus will be on the decision of the Ecuadorean government, it is just as important that we remember Bradley Manning has been detained without trial for over 800 days," he said, referring to the former US soldier accused of leaking government material to Wikileaks.
Mr Assange is expected to make a statement in front of the embassy on Sunday at 14:00 BST, according to the Wikileaks Twitter feed.
Announcing Ecuador's decision, Mr Patino launched a strong attack on the UK for what he said was an "explicit type of blackmail".
The UK Foreign Office had warned, in a note, that 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 Hague said it was a "matter of regret" that the Ecuadorean government decided to grant Mr Assange political asylum but warned that it "does not change the fundamentals" of the case.
He also warned that it could drag on for some "considerable" time.
"We will not allow Mr Assange safe passage out of the United Kingdom, nor is there any legal basis for us to do so," he said.
Mr Hague said there was "no threat" to storm the embassy.
"We are talking about an Act of Parliament in this country which stresses that it must be used in full conformity with international law," he said.
Mr Patino said Ecuador believed Mr Assange's fears of political persecution were "legitimate" and said his country was being loyal to its tradition of protecting those who were vulnerable.
He later told BBC Mundo that conditions were attached to the asylum.
"We placed the same type of conditions that are the norm in international relations, such as him [Mr Assange] not making political statements that could affect our relations with friendly countries."
The Foreign Office said it was "disappointed" by the Ecuador statement and said it remained committed to reaching a "negotiated solution" that would allow it to carry out its "obligations under the Extradition Act". This means Mr Assange's arrest would still be sought if he left the embassy.
Sweden summons ambassador
The Swedish government reacted angrily to Mr Patino's suggestion that Mr Assange would not be treated fairly by its justice system, summoning Ecuador's ambassador to explain.
"The accusations... are serious, and it is unacceptable that Ecuador would want to halt the Swedish judicial process and European judicial co-operation," said Anders Joerle, spokesman for the Swedish foreign ministry.
The Organisation of American States called a special meeting at its Washington headquarters on Thursday to discuss the Ecuador-UK relationship, specifically Ecuador's diplomatic premises in the UK.
The Union of South American Nations, meanwhile, has convened an "extraordinary meeting" in Ecuador on Sunday to consider "the situation raised at the embassy".
Mr Assange entered the embassy after the UK's Supreme Court dismissed his 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 that of the US, in 2010.
Mr Assange says he fears that if extradited to Sweden, he will then be passed on to the American authorities.
In 2010, two female Wikileaks supporters accused Mr Assange 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.