LONDON — WikiLeaks founder Julian Assange was sentenced by a British judge on Wednesday to 50 weeks in prison for skipping bail and hiding out for seven years in the Ecuadorean Embassy in London.

Assange failed to report to a police station in June 2012 when he faced extradition to Sweden on charges of sexual assault and rape.

He claims he sought refuge because he feared subsequent extradition to the United States, where he has since been charged with leaking classified American military documents.

Instead of reporting to police, Assange entered the Ecuadorean Embassy, gained diplomatic asylum and remained there for 2,487 days.

The asylum was revoked last month and he was dragged out of the building by police. On Wednesday, Assange, 47, was sentenced in London's Southwark Crown Court.

Judge Deborah Taylor told the court it was "difficult to envisage a more serious example of this offense."

Assange's decision to remain in the embassy for seven years cost the British taxpayer 16 million pounds ($21 million), largely due to the extensive police surveillance on the building.

The judge told Assange he was guilty of "exploiting your privileged position to flout the law and advertise internationally your disdain for the law of this country."

Kristinn Hrafnsson the editor-in-chief of Wikileaks called the sentence "outrageous" and "vindictive in nature."

"What is at stake there could be a question of life and death for Mr. Assange," Hrafnsson said Wednesday. "It is also a question of life and death for major journalistic principle."

Assange apologized unreservedly for skipping bail and his defense team argued he had done so because he was a "desperate man" who wanted to avoid extradition to the U.S., The Associated Press reported.

However, the judge noted that he has previously pleaded not guilty, and his mitigation Wednesday was only "the first recognition that you regret your actions."

After the sentence was handed down, Assange's supporters chanted "shame on you!" from the public gallery as he was led away. Outside the court, more demonstrators chanted, "Free, free, Julian Assange!" and held banners with messages such as, "Assange's freedom is our freedom."

Assange, who is Australian, faces a separate legal fight against the extradition request from the U.S., where he is charged with conspiring with Chelsea Manning, the former Army intelligence analyst, to hack into U.S. military intelligence files. If convicted, Assange faces a maximum five-year sentence.

"The focus of our energies will now be on fighting that extradition request and that fight starts tomorrow," his lawyer Jennifer Robinson said.

Manning was sentenced to 35 years in prison, but her sentence was commuted by President Barack Obama in 2017 after seven years.

Assange will appear in court again Thursday via video link to hear the extradition order, and again on June 12. The process could take up to two years and possibly longer.

Depending on the outcome and timing of Brexit, Assange could potentially take his case from the U.K. courts to the European Court of Justice in Strasbourg, France, the legal arbiter for E.U. states.

CORRECTION (May 1, 09:27 a.m. ET): An earlier version of this article misstated the amount London police spent on watching the Ecuadorian Embassy while Julian Assange was inside. It was 16 million pounds ($21 million), not £6 million.