London: A British court sentenced Julian Assange, the WikiLeaks founder, to 50 weeks in jail Wednesday for jumping bail when he took refuge in Ecuador’s Embassy in London seven years ago.

His complex legal travails are far from over: The United States is seeking Assange’s extradition for prosecution there and officials in Sweden have left open the possibility that he could face criminal charges in that country.

Assange faces a charge of conspiracy to hack into a Pentagon computer network. A federal indictment accuses him of helping an Army private to illegally download classified information in 2010, much of it about the wars in Iraq and Afghanistan, which WikiLeaks then made public. He has denied the charge.

Assange, 47, was arrested April 11 after the Ecuadorean government withdrew its protection of him and allowed police to take him out of the embassy in London, where he had lived since 2012. The same day, he appeared in court and was convicted on the charge of skipping bail.

Assange argued that he should not be jailed for the offence, because he was effectively imprisoned in the embassy. On Wednesday, in Crown Court in the Southwark section of London, Judge Deborah Taylor rejected that claim and said that he could have left at any time.

His legal odyssey began in 2010, when prosecutors in Sweden sought to question him about alleged sexual assaults there, which he denies. Eventually, he had to post bail to remain free while fighting extradition to Sweden, which he insisted would then send him to the United States.

After exhausting his appeals in the British courts, rather than submit to extradition, Assange took refuge in Ecuador’s Embassy, violating the terms of his bail. Ecuador granted him asylum and, eventually, citizenship.

He continued his work from the embassy, and in 2016, WikiLeaks released thousands of emails hacked from the Democratic National Committee and the personal account of John Podesta, chairman of Hillary Clinton’s campaign, intending to harm her candidacy. Special counsel Robert Mueller concluded that the emails were stolen by Russian intelligence agents, which Assange denies.

The 2010 release of Pentagon records was made possible by Chelsea Manning, then known as Bradley Manning, the Army private who would later serve around seven years in prison for taking them. The indictment against Assange says he did not merely publish the material provided by Manning, but helped her in the hacking, which he disputes.

Assange insists that the government is seeking retribution for his exposure of misconduct and deception by US troops and officials.

Swedish prosecutors eventually dropped the case against Assange, calling it pointless to pursue it, but said they could revive it if he became available. Nevertheless, the bail-jumping charge, and the threat of extradition to the United States, still hung over him.

Last month, Ecuador revoked his asylum and citizenship, citing a list of grievances that had made him an unwanted house guest, ranging from recent WikiLeaks releases to alleged ill manners, threats, hacking aimed at Ecuador, and abuse of embassy staff members and facilities.

Ecuador stopped sheltering Assange after “his repeated violations to international conventions and daily-life protocols,” President Lenin Moreno said in a statement on Twitter.

But Assange did not go easily: He resisted arrest and had to be restrained by British police officers, who struggled to handcuff him.

“This is unlawful, I’m not leaving,” he told them, according to the account given at the Westminster Magistrates Court, where Assange appeared later that day. In the end, he had to be dragged out of the embassy.

Assange, a man accustomed to celebrity and internet culture, has long fascinated and divided popular opinion: To supporters, he is a martyr for the cause of free speech, but others see him as a publicity-seeking criminal with strong ties to the Kremlin.

He has indicated that he would fight extradition and the process promises to be a long one, further extending his saga.