WikiLeaks founder Julian Assange was sentenced Wednesday to 50 weeks in a British prison for jumping bail in 2012.

He apologized to the court, but the judge said he had used his “privileged position” to show disdain for British law.

Assange next faces an extradition hearing on Thursday related to a separate and potentially more consequential charge in the United States of conspiring to crack a government password. Legal experts anticipate the extradition fight could take years.

Assange, 47, appeared at Southwark Crown Court in London wearing a black jacket and gray sweater, the bushy white beard seen during his arrest last month now neatly trimmed. He answered the judge in a quiet voice from behind a glass wall in a bland courtroom packed with journalists taking notes.

The Australian citizen had faced up to a year in a British prison for his bail violation — the maximum penalty for such an offense. He broke his bail conditions in 2012 when he fled to the Ecuadoran Embassy in London after Sweden requested his extradition in an investigation involving sexual assault allegations, including rape. Assange has denied those accusations.

In court Wednesday, defense attorney Mark Summers argued that Assange failed to surrender to a British court seven years ago and so violated his bail because he was terrified that if he were extradited to Sweden, he would quickly be handed over to U.S. authorities — and could even be sent to Guantanamo Bay — for his part in leaking a trove of classified U.S. government documents.

Assange thought he could be “kidnapped” by the United States and was “living under overwhelming fear of rendition,” Summers told the court.

“It matters little whether his fears were reasonable or unreasonable,” he added, suggesting that those fears were, in fact, reasonable.

Summers then read aloud a handwritten letter in which Assange said that “I apologize unreservedly” for seeking refuge at the embassy.

“I found myself struggling with terrifying circumstances,” Assange wrote. “I did what I thought at the time was the best and perhaps the only thing that could be done.”

The letter continued: “I regret the course that this took. The difficulties were instead compounded and impacted upon very many others.”

Judge Deborah Taylor said that Assange could have left the embassy and surrendered at any time — rather than waiting for Ecuador to kick him out — and that he used his asylum at the Ecuadoran Embassy to insult the British judiciary. She mentioned that British police had spent 16 million pounds (nearly $21 million) securing and watching the embassy, where until recently Assange had continued to wage his campaigns on the Internet. 

“It’s difficult to envisage a more serious example of this offense,” Taylor said in her sentencing remarks.

“By entering the embassy, you deliberately put yourself out of reach, whilst remaining in the U.K.,” she told Assange. “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.”

Assange’s actions, she said, “undoubtedly affected the progress of the Swedish proceedings” in the sexual assault case.  

Sweden discontinued its sex crimes investigation against Assange in 2017. But after his arrest in London last month, Swedish prosecutors said they were considering reopening the investigation.

Two dozen Assange supporters were present in the courtroom. After he was sentenced, some of them shouted “Shame!” Assange raised a fist in solidarity as he was led away.

His lawyer characterized Assange’s years in the Ecuadoran Embassy as living in cramped, hostile conditions, with no access to appropriate medical care or a garden, and under constant monitoring — as a virtual incarceration in “circumstances of pain and oppression.”

“He was a desperate man,” Summers said.

Assange occasionally received visitors, including the actress Pamela Anderson. He was dramatically arrested on April 11 after Ecuador revoked his asylum. Hours later, U.S. prosecutors unsealed a federal indictment charging Assange with conspiring to help Army intelligence analyst Chelsea Manning — known as Bradley Manning at the time of Assange’s alleged offenses — to obtain secret U.S. government documents.

Assange’s lawyers have vowed to fight extradition to the United States.

Assange’s father, John Shipton, recently appeared on television calling for his son’s repatriation to Australia. He also speculated that his son was evicted from the embassy because the Ecuadorans had made a deal with the United States in exchange for a loan from the International Monetary Fund.

Ecuador “uses the United States dollar,” Shipton told the “60 Minutes Australia” program. “It got an IMF loan, and you can’t get an IMF loan unless the United States approves it.”