LONDON - A British judge on Monday ruled against the extradition of Julian Assange to the United States, granting the WikiLeaks founder a major victory against the U.S. authorities who have accused him of conspiring to hack government computers and violating the Espionage Act with the release of confidential communications in 2010 and 2011.

Mr. Assange, 49, was indicted in 2019 on 17 counts of violating the Espionage Act for his role in obtaining and publishing secret military and diplomatic documents, acts that could result in a sentence of up to 175 years in prison if he were found guilty on all charges. He was also indicted on one count of violating the Computers Fraud and Abuse Act, bringing the total of charges to 18.

The judge, Vanessa Baraitser of the Westminster Magistrates’ Court, said in Monday’s ruling that she was satisfied that the American authorities had brought forth the case “in good faith,” and that Mr. Assange’s actions went beyond simply encouraging a journalist. But she said there was evidence of a risk to Mr. Assange’s health if he were to face trial in the United States, noting that she found “Mr. Assange’s risk of committing suicide, if an extradition order were to be made, to be substantial.”

The ruling on Monday at the Central Criminal Court in London, known as the Old Bailey, was a major turning point in a legal struggle that has spanned more than a decade. But that battle may drag for at least several months or even another year, as U.S. prosecutors will appeal the decision. The authorities have 15 days to appeal.

A crowd of supporters gathered outside the courthouse in central London erupted in cheers when the verdict was delivered.

Mr. Assange, who is Australian, rose to prominence in 2010 by publishing documents provided by the former U.S. Army intelligence analyst Chelsea Manning. He then took refuge at the Ecuadorean Embassy in London to escape extradition to Sweden, where he faced rape charges that were later dropped. In the meantime, he kept running WikiLeaks as a self-proclaimed political refugee. He spent several years there before his eventual arrest by the British police.

During the extradition hearing, which began in February but was postponed because of the coronavirus pandemic, lawyers representing the United States argued that Mr. Assange had unlawfully obtained secret document archives, and that he had put lives at risk by revealing the names of people who had provided information to the United States in dangerous places like war zones.

“The greatest risk for him in the U.S. is that he won’t face a fair trial,” said Greg Barns, an Australian lawyer and adviser to Mr. Assange. “Then he could spend the rest of his life in prison, in solitary confinement, treated in a cruel and arbitrary fashion.”