LONDON — In his two- decade odyssey from Australian hacker to new-age media celebrity, hunted figure, perennial prisoner and, finally, a free man, Julian Assange has always been easier to caricature than characterize.

The lack of an agreed-upon label for Assange — is he a heroic crusader for truth or a reckless leaker who endangered lives? — makes any assessment of his legacy ambiguous at best.

Whatever history’s judgment of Assange, his appearance Wednesday in a courtroom on a remote Pacific island, where he pleaded guilty to a single count of violating the U.S. Espionage Act, was an appropriate coda to a story that has always seemed stranger than fiction.

From the time he established WikiLeaks in 2006, Assange, 52, was a polarizing figure, using the internet to solicit and publish government secrets. His disclosures, from confidential diplomatic cables to civilian deaths in the American wars in Afghanistan and Iraq, made him courageous to those who believed in his gospel of radical transparency. To others who feared that the information he revealed could get people killed, he was destructive, even if there was never proof that lives were lost.

After his sensational leaks incurred the wrath of the White House, Assange spent 12 years in London fighting extradition, first to Sweden and then to the United States. Holed up in a South American embassy and later languishing in a British prison, he resurfaced in the headlines whenever a court ruled on his latest appeal. He became less a cutting-edge insurgent than a ghostly throwback to another time.

“Julian Assange has for so many years sacrificed for the freedom of speech, freedom of the press,” Barry Pollack, a lawyer who represented Assange in his plea negotiations with U.S. authorities, said Wednesday in Canberra, Australia. “He’s sacrificed his own freedom.”

At its best, WikiLeaks shone a light into dark corners, often working with traditional media organizations to expose abuses like extrajudicial killings in Kenya. Documents posted by WikiLeaks about the excesses of Tunisia’s ruling family presaged the upheaval that swept the region.

Alan Rusbridger, a former editor-in-chief of The Guardian who worked extensively with Assange, said WikiLeaks deserved credit for accelerating the political changes of the Arab Spring.

While Assange indisputably changed history, it is not clear that he did so in the way that he and his apostles may have hoped when they came to global prominence in 2010 by posting video on WikiLeaks of a U.S. helicopter strike in Baghdad that had resulted in the death of a Reuters photographer.

“Think about Julian Assange’s motivation regarding Iraq and Afghanistan,” said P.J. Crowley, who was the State Department’s spokesperson when WikiLeaks published 250,000 confidential diplomatic cables in 2010, a project on which the site initially collaborated with The New York Times and others.

“We left Iraq, went back and are still there,” Crowley said. “We stayed in Afghanistan for a decade after WikiLeaks. His legacy is collaborating with Russian intelligence, whether wittingly or unwittingly, to help Russia elect Donald Trump.”

Crowley’s experience with Assange is acutely personal: He was forced to resign his post after he criticized the Pentagon’s treatment of Chelsea Manning, the U.S. Army intelligence analyst who downloaded thousands of documents, including those cables, from a classified government network and uploaded them to WikiLeaks.

Views of Assange soured after WikiLeaks, in the heat of the 2016 presidential campaign, published Democratic emails that had been hacked by a Russian intelligence agency. Allies of Hillary Clinton cited it as one of multiple factors that contributed to her defeat by Trump.

As secretary of state, Clinton had to apologize to foreign leaders for embarrassing details in cables sent by American diplomats to the State Department. In one case, the foreign minister of a Persian Gulf nation refused to allow note- takers into a meeting with her, for fear that his comments would be leaked.

“Some of this damage to American foreign policy was irreparable,” said Vali Nasr, a senior State Department official at the time who now teaches at Johns Hopkins University. “You can apologize for it, but you can’t undo it.”

But Nasr said the furor caused by WikiLeaks also revealed something that the United States was later able to use to its advantage: the public relations value of intelligence. Before Russia’s invasion of Ukraine, American and British intelligence agencies selectively declassified material about Russia’s activities to caution President Vladimir Putin and mobilize Western support.

American officials justified their prosecution of Assange on espionage charges by saying it would deter other would-be whistleblowers from leaking classified material. But it also reflected a collective sense of shock that the nation’s most tightly held secrets could be so easily compromised.

“Some of this going after Assange,” Nasr said, “had to do with compensating for your weakness by shooting the messenger.”

The messenger proved elusive. Assange’s prolonged exile in Britain, during which he spent seven years in the Ecuadorean Embassy and five years in London’s Belmarsh prison, turned him from a swashbuckling media impresario into a haunted, if hardheaded, resistance figure.

Supporters camped outside the embassy, where he had been granted asylum, holding placards and chanting “Free Assange!” Detractors saw him as an erratic publicity seeker. Claiming to be a victim of political persecution, he violated his bail terms after losing his appeal of a Swedish arrest warrant on charges of sexual assault — charges he described as a “smear campaign” ginned up by the United States.

From his cramped living quarters in a converted embassy office, Assange gave defiant media interviews. He began a secret relationship with Stella Moris, a lawyer who represented him and later became his wife. They had two children while he was hiding out in the embassy.

Champions of press freedom agree that even with Assange’s release, the plea deal set a troubling precedent.

Jameel Jaffer, the executive director of the Knight First Amendment Institute at Columbia University, said that while the agreement averted the “worst-case scenario for press freedom,” it also means that Assange “will have served five years in prison for activities that journalists engage in every day.”