LONDON (Reuters) - WikiLeaks founder Julian Assange was sentenced to 50 weeks in prison by a British court on Wednesday for skipping bail when he holed up in Ecuador’s London embassy for seven years until police dragged him out last month.

Assange sought refuge in the embassy in June 2012 to avoid an extradition order to Sweden over an allegation of rape, which he denies.

His lawyer argued it was an act of desperation to avoid being passed to the United States to face action over the release of thousands of secret U.S. diplomatic cables.

Many of the documents related to wars, national security and other issues, and some were often highly critical appraisals of world leaders such Russian President Vladimir Putin and the Saudi royal family. The United States has charged him with conspiracy and seeks his extradition.

But handing down what was nearly the maximum possible sentence, Judge Deborah Taylor told Assange he had exploited his privileged position to flout the law and express his disdain for British justice.

“Whilst you may have had fears as to what may happen to you, nonetheless you had a choice,” Taylor told Assange, dressed in a black jacket and gray sweatshirt, at Southwark Crown Court.

“It is difficult to envisage a more serious example of this offence.”

Assange made international headlines in early 2010 when WikiLeaks published a classified U.S. military video showing a 2007 attack by Apache helicopters in Baghdad that killed a dozen people, including two Reuters news staff.

To some, Assange is a hero for exposing what supporters cast as abuse of power by modern states and for championing free speech. But to others, he is a dangerous rebel who has undermined U.S. security.

Slideshow ( 9 images )

After his sentence was announced, supporters in the public gallery got to their feet to cheer him, before raising their arms and chanting “shame on you” to the court.

The case in Britain arose after Australian-born Assange, 47, was accused by two Swedish women of sexual assault and rape in 2010. Assange fought through the courts to get an extradition order and the preliminary investigation dropped.

He fled to Ecuador’s embassy in June 2012 after exhausting all legal options and was granted asylum two months later. The Swedish allegations were dropped in 2017, but authorities there might revive them.

Just hours after police finally removed from the Ecuadorean embassy in London on April 11, U.S. prosecutors said they had charged Assange with conspiracy in trying to access a classified U.S. government computer. He was convicted on the charge of jumping bail the same day.

“TERRIFYING CIRCUMSTANCES”

In a letter read out at the hearing in London, Assange said he regretted how matters how panned out.

“I apologize unreservedly to those who consider that I have disrespected them by the way I have pursued my case. This is not what I wanted or intended,” Assange said in the letter to the judge read out by his lawyer, Mark Summers.

“I found myself struggling with terrifying circumstances for which neither I nor those from whom I sought advice could work out any remedy. I did what I thought at the time was the best.”

Slideshow ( 9 images )

Summers told the court that Assange had “strongly held fears” in 2012 that he would be sent from Sweden to the United States and ultimately to the Guantanamo Bay detention center in a U.S. naval base in Cuba.

Summers cited the arrest and treatment of Chelsea Manning, a U.S. Army soldier who served seven years in military prison for leaking classified data while she was working as an intelligence analyst in Iraq.

Assange’s lawyer said Manning, who is transgender, had been subjected to sleep deprivation and forced to parade naked in front of military personnel.

Summers said the fact Assange chose indefinite detention in small rooms at the Ecuadorean Embassy, in a state of depression and pain for various medical ailments, rather than spend 12 months in a British jail, showed the extent of his fears.

But Judge Taylor rejected the arguments, saying they offered limited mitigation for his actions and that it had cost British taxpayers 16 million pounds ($21 million) to ensure he was arrested when he left the embassy.

The sentence does not end British legal proceedings. On Thursday, there will be hearing in another London court as part of a U.S. extradition case.

“Tomorrow...is the start of the big and most important fight,” Kristinn Hrafnsson from WikiLeaks said outside court. “What is at stake there? It could be a question of life and death for Mr Assange.”