An editorial opinion (16 August 2012) from The Guardian was that Assange is not entitled to protection under the 1951 UN refugee convention.
Refugee protection does not apply to the WikiLeaks founder and it is wrong of him to claim it
As defined by the United Nations convention on refugees, a refugee is
a person who "owing to well founded fear of being persecuted for
reasons of race, religion, nationality, membership of a particular
social group or political opinion, is outside the country of his
nationality and is unable or, owing to such fear, is unwilling to
avail himself of the protection of that country". A little later on,
the text of the convention specifically states that refugee status
"shall not apply to any person with respect to whom there are
serious reasons for considering that … he has committed a serious
non-political crime outside the country of refuge".
Whatever views one may have about Julian Assange as a WikiLeaks
activist, it is clear that in legal and moral terms he cannot properly
be described as a refugee. [...] Since Mr Assange is wanted by the
courts in Sweden for the specific and proper purpose of answering two
allegations of sexual assault, which is in anyone's language a serious
non-political crime, it is also clear that he is specifically
disbarred from being treated as a refugee.
None of this fundamental aspect of Mr Assange's status was discussed
in any serious way on Thursday by the Ecuadorian foreign minister etc.
The BBC has a similar opinion
The Convention Relating to the Status of Refugees, which both the UK
and Ecuador have ratified, says that its protections do not apply to
"any person with respect to whom there are serious reasons for
considering that… he has committed a serious non-political crime
outside the country of refuge prior to his admission to that country
as a refugee".
The allegations faced by Mr Assange in Sweden are sexual assault and
rape - serious non-political crime.
In summary, in appears that Assange and Ecuador both claim that Assange's asylum in the embassy is justified by his being a refugee. It's not clear that theirs was a legally-justified decision. The Guardian suggests that Ecuador's decision was political/diplomatic:
Ecuador has found a way to tweak the tail of the imperialist lion, but the law is not on Ecuador's side and, in the end, the law should be upheld.
This Wikipedia article summarizes Assange's pleadings in UK courts. The courts ruled against Assange, even at the Supreme Court level when the cause was appealed.
Extradition hearing
The extradition hearing took place on 7–8 and 11 February 2011 before
the City of Westminster Magistrates' Court sitting at Belmarsh
Magistrates' Court in London.[46][47] Assange's lawyers at the
extradition hearing were Geoffrey Robertson QC and Mark Stephens,
human rights specialists, and the prosecution was represented by a
team led by Clare Montgomery QC.[48] Arguments were presented as to
whether the Swedish prosecutor had the authority to issue a European
Arrest Warrant, the extradition was requested for prosecution or
interrogation, the alleged crimes qualified as extradition crimes,
there was an abuse of process, his human rights would be respected,
and he would receive a fair trial if extradited to Sweden.
Extradition decision
The outcome of the hearing was announced on 24 February 2011, when the
extradition warrant was upheld.[49][50][51] Senior District Judge
Howard Riddle found against Assange on each of the main arguments
against his extradition.[52] The judge said "as a matter of fact, and
looking at all the circumstances in the round, this person (Mr
Assange) passes the threshold of being an accused person and is wanted
for prosecution."[52] Judge Riddle concluded: "I am satisfied that the
specified offences are extradition offences."[52]