London -- A British judge sentenced WikiLeaks founder Julian Assange on Wednesday to 50 weeks in prison for skipping bail seven years ago and holing up in the Ecuadorian embassy. Judge Deborah Taylor said it was hard to imagine a more serious version of the offense as she gave the 47-year-old hacker a sentence close to the maximum of a year in custody.

She said Assange's seven years in the embassy had cost British taxpayers 16 million pounds ($21 million), and said he sought asylum as a "deliberate attempt to delay justice."

The white-haired Assange stood impassively with his hands clasped while the sentence was read. His supporters in the public gallery at Southwark Crown Court chanted "Shame on you" at the judge as Assange was led away.

Get Breaking News Delivered to Your Inbox

The Australian secret-spiller sought asylum in the South American country's London embassy in June 2012 to avoid extradition to Sweden, where he was wanted for questioning over rape and sexual assault allegations.

Assange's lawyer Mark Summers told a courtroom packed with journalists and WikiLeaks supporters that his client sought refuge in the Ecuadorian Embassy because "he was living with overwhelming fear of being rendered to the U.S."

He said Assange had a "well-founded" fear that he would be mistreated and possibly sent to the U.S. detention camp for terrorism suspects at Guantanamo Bay.

Summers read a letter from Assange apologizing for his behavior in 2012 and saying "I did what I thought was best."

"I found myself struggling with terrifying circumstances," the letter said.

WikiLeaks founder Julian Assange arrives at court in London, May 1, 2019, to be sentenced for bail violation. He was sentenced to 50 weeks in prison. Getty

Assange was arrested April 11 after Ecuador revoked his political asylum, accusing him of everything from meddling in the nation's foreign affairs to poor hygiene.

He faces a separate court hearing Thursday on a U.S. extradition request. American authorities have charged Assange with conspiring to break into a Pentagon computer system.