Julian Assange has been sentenced to 50 weeks in prison for breaching bail and spending seven years holed up in the Ecuadorian embassy in London.

The Wikileaks founder took refuge in the building in 2012 to avoid extradition from the UK to Sweden where he faced allegations of sexual assault.

Sentencing at a packed Southwark Crown Court, Judge Deborah Taylor said: “You remained there ... exploiting your privileged position to flout the law and advertise internationally your disdain for the law of this country.”

Assange now faces a separate hearing on Thursday to decide if he can be extradited to the US where he is accused of orchestrating one of the largest ever leaks of government secrets.

The sentencing hearing on Wednesday heard how the 47-year-old Australian had remained living in Ecuador’s embassy – out of reach of British police – until his asylum was withdrawn last month and officers were invited in to arrest him.

Key moments for Julian Assange Show all 9 1 /9 Key moments for Julian Assange Key moments for Julian Assange The situation today Assange was arrested after Metropolitan Police officers were invited into the Ecuadorian embassy on April 11 2019. How did it come to this? Ruptly TV Key moments for Julian Assange The break Assange shows the front page of the Guardian on July 26 2010, the day that they broke the story of the thousands of military files leaked by WikiLeaks AFP/Getty Key moments for Julian Assange Wanted A warrant for Assange's arrest was issued in August 2010 for counts of rape and molestation in Sweden AFP/Getty Key moments for Julian Assange Ruling The UK's Supreme Court ruled in 2012 that Assange should be extradited to Sweden to face trial Getty Key moments for Julian Assange Sanctuary Following the ruling, Assange was given asylum by the Ecuadorian governement over fears that his human rights would be violated if he were extradited, he has since remained in the embassy in London Getty Key moments for Julian Assange A friend in Pam Friend Pamela Anderson delivers lunch to Assange at the embassy in October 2016. She has since spoken against his arrest Getty Key moments for Julian Assange Arbitrarily detained A UN panel found in 2016 that Assange had been arbitrarily detained and that he had not been able to claim his full right to asylum. It urged Sweden to withdraw the charges against him Getty Key moments for Julian Assange The cat ultimatum Last year, the Ecuadorian embassy threatened to revoke Assange's internet access unless he stopped making political statements online and started taking better care of James, his pet cat. Assange accused Ecuador of violating his rights Reuters Key moments for Julian Assange Arrest Assange was arrested on April 11 2019. Ecuador revoked his asylum status and invited the Metropolitan Police in to the embassy to arrest him. Reuters

In a letter read out in court, Assange apologised to “those who consider that I have disrespected them by the way that I have pursued my case”.

He added: “This is not what I wanted or intended. I found myself struggling with terrifying circumstances for which neither I nor those from whom I sought advice could work out any remedy. I did what I thought at the time was the best.”

Mark Summers QC, for Assange, said the secret-spiller had only gone on the run because he believed he may end up at America’s infamous prison camp Guantanamo Bay.

“The fear was [of] onward removal from Sweden to America and even Guantanamo Bay,” said Mr Summers.

He added: “[There were] suggestions from inside the US administration that he could be kidnapped wherever he was with or without the approval of the country in which he was residing and brought forcibly to the US. That is no less than the threat of a rendition.”

But Judge Taylor dismissed the claim and said it was difficult to imagine a more serious example of a breach of bail case.

“By hiding in the embassy you deliberately put yourself out of reach, while remaining in the UK,” she said, adding he had cost the British taxpayer £16m.

As the convict was led down to the cells, he raised a defiant fist to supporters in the public gallery.

Sweden itself has since withdrawn its extradition request for Assange – who denies the allegations – but he remains wanted in the US on charges of conspiring to hack into Pentagon computers and aiding whistleblower Chelsea Manning. He faces up to five years in prison if extradited and found guilty.

Support free-thinking journalism and attend Independent events

The accusations date back to 2006 when Wikileaks published hundreds of thousands of secret diplomatic cables and files that laid bare US intelligence and was said to have put the lives of hundreds of its staff at risk.