What just happened? Julian Assange, the WikiLeaks founder who spent almost seven years inside the Ecuadorian embassy in the UK before his arrest last month, has been sentenced to 50 weeks in prison for breaching his 2012 bail conditions.

The Australian national was given refuge at the residence in 2012 while on bail in the UK over charges of sexual assault and rape in Sweden, which he denies. But on April 11, Assange was arrested after the Ecuadorian government withdrew his asylum claim.

Assange was found guilty of breaching the bail act last month and was sentenced today. The 50-weeks handed down by judge Deborah Taylor was just short of the maximum one-year sentence.

Assange told the court he had been "struggling with difficult circumstances," and apologized to those who "consider I've disrespected them."

"I did what I thought at the time was the best or perhaps the only thing that I could have done," he said. His lawyer added that Assange was forced to take action as he feared "kidnap and torture" by the US. Because of his work on WikiLeaks, Assange was said to be "gripped" by fears of rendition to America.

Judge Taylor told Assange that "by hiding in the embassy you deliberately put yourself out of reach, while remaining in the UK."

"You exploited your privileged position to flout the law and advertised internationally your disdain for the law of this country," she added, noting that the policing resources outside of the embassy during the time he was there cost the taxpayer £16 million.

Assange will face a hearing on Thursday related to his potential extradition to the US over allegations that he conspired with former US intelligence analyst Chelsea Manning to download classified databases. If found guilty, he could be sentenced to five years in prison.