Ecuador granted political asylum to WikiLeaks founder Julian Assange on Thursday, setting up a diplomatic confrontation with Britain, which plans to extradite him to Sweden.

Ecuadoran Foreign Minister Ricardo Patino argued the Australian activist would not get a fair trial if he is eventually sent to the United States to be tried for publishing a trove of classified documents.

"The Ecuador government, loyal to its tradition to protect those who seek refuge with us at our diplomatic missions, has decided to grant diplomatic asylum to Mr Assange," Patino said, at a news conference.

The decision escalated a crisis set in motion when Assange (41) took refuge in the Ecuadoran embassy in London on June 19 to avoid extradition to Sweden, where he is wanted for questioning in a sexual assault case.

Britain insisted it would carry out its "obligation" to extradite Assange regardless of the Ecuadoran decision and Sweden immediately rejected Patino's argument that Assange would not be treated fairly.

The Ecuadoran said his government reached its decision after Britain, Sweden and the United States refused to provide guarantees that Assange would not be extradited to the United States.

In 2010, WikiLeaks obtained and published online an enormous cache of US military documents on the war in Iraq and Afghanistan and diplomatic cables that deeply embarrassed the United States.

A US army private, Bradley Manning, faces trial in the US military courts later this year for allegedly passing the classified material to WikiLeaks.

"If he were extradited to the United States, Mr Assange would not receive a fair trial and could be judged by special tribunals or military courts," Patino said.

"It is not implausible that he would be subjected to cruel and degrading treatment and be condemned to life in prison or capital punishment."

Patino said Assange's imprisonment in Sweden "would open up a chain of events that would impede his avoiding extradition to a third country."

"As a result, Ecuador feels his arguments mean his fears are genuine, that he could be the victim of political persecution because of his decisive defense of the freedom of expression and the freedom of the press," he said.

Patino said that if Britain did not grant Assange safe conduct out of the country, he would remain "under the protection of our embassy."

He said the Ecuadoran action should not lead to a rupture in relations between the two countries, calling it "a sovereign decision protected by international law."

But the British Foreign Office expressed disappointment and said the Ecuadoran decision changed nothing.

"Under our law, with Mr Assange having exhausted all options of appeal, the British authorities are under a binding obligation to extradite him to Sweden. We shall carry out that obligation," a Foreign Office spokeswoman said.

Swedish Foreign Minister Carl Bildt took to his Twitter account to respond.

"Our firm legal and constitutional system guarantees the rights of each and everyone. We firmly reject any accusations to the contrary," he said.