LONDON—Julian Assange has been sentenced to 50 weeks in prison after being found guilty of bail-skipping charges in Britain.

The WikiLeaks founder was arrested and dragged out of London’s Ecuadorian embassy by British police in April. For the seven years he was holed up in the building, he had an outstanding warrant for jumping bail in 2012 to avoid extradition to Sweden, where he faced rape charges.

Assange apologized in court for breaching his bail—but it wasn’t enough for the judge show him any leniency. Fifty weeks was just below the maximum possible sentence of 12 months in prison, and the judge told Assange that his case was “exceptional in seriousness” and said “by entering the embassy, you deliberately put yourself out of reach.”

“You remained there for nearly seven years, exploiting your privileged position to flout the law and advertise internationally your disdain for the law of this country,” said Judge Deborah Taylor, adding that Assange’s time in the embassy had cost British taxpayers £16 million ($21 million.)

In a letter read to the court, Assange said he had found himself “struggling with difficult circumstances” and complained that he had been suffering from depression and a toothache. He apologized to anyone who “consider[s] I’ve disrespected them,” and added: “I did what I thought at the time was the best or perhaps the only thing that I could have done.”

Immediately after his sentencing, Assange raised his fist to supporters in the courtroom and was taken down to the cells. They reportedly shouted “Shame on you!” at the judge as Assange disappeared from view.

British police also arrested Assange last month on behalf of U.S. authorities who have charged him with illegally helping Chelsea Manning to crack a computer password to steal thousands of classified documents.

The U.S. Department of Justice revealed at the time that the arrest was over a federal charge of “conspiracy to commit computer intrusion” and relates to the WikiLeaks founder’s alleged role in what it calls “one of the largest compromises of classified information” in U.S. history.

Assange will face a hearing on those extradition charges Thursday. He could be hit with as much as five years in a U.S. prison if extradited and convicted.

Read more at The Daily Beast.