WikiLeaks founder Julian Assange has been sentenced to 50 weeks in jail for violating his bail conditions after seven years holed up inside the Ecuadorian Embassy in London.

The whistleblower sought refuge at the London address in 2012 after he was accused of sexual offences in Sweden.

But the 47-year-old was finally arrested last month after years inside the building, and now faces extradition to the US over leaks of classified information.

The extradition request will be heard by a London court on Thursday.

In a letter read to court, Assange said: “I apologise unreservedly to those who consider that I have disrespected them by the way I pursued my case.

“I found myself struggling with difficult circumstances.

“I did what I thought at the time was the best or perhaps the only thing that I could have done.

“I regret the course that that has taken.”

Those difficulties, the letter continued, were “compounded” and also “impacted upon very many others”.

In mitigation for Assange, Mark Summers QC told the court his client had been “gripped” by fears of rendition to the US over the years because of his work with WikiLeaks.

He said: “As threats rained down on him from America, they overshadowed everything as far as he was concerned.

“They dominated his thoughts. They were not invented by him, they were gripping him throughout.”

The US Justice Department said Assange was charged with conspiring with former Army intelligence analyst Chelsea Manning to gain access to a government computer as part of a 2010 leak by WikiLeaks of hundreds of thousands of US military reports about the wars in Afghanistan and Iraq and American diplomatic communications.