SAIPAN, NORTHERN MARIANA ISLANDS -- WikiLeaks founder Julian Assange has pleaded guilty to obtaining and publishing U.S. military secrets in a deal with Justice Department prosecutors that secures his liberty and concludes a drawn-out legal saga that raised divisive questions about press freedom and national security.

The plea was entered Wednesday morning in federal court in Saipan, the capital of the Northern Mariana Islands, an American commonwealth in the Pacific, that is relatively close to Assange's native Australia and that accommodated his desire to avoid setting foot inside the continental United States.

The deal required the iconoclastic internet publisher to admit guilt to a single felony count but also permitted him to return to Australia without any time in an American prison. He had been jailed in the United Kingdom since 2019, fighting extradition to the United States on an Espionage Act indictment that could have carried a lengthy prison sentence in the event of a conviction, and for seven years before that was holed up in the Ecuadorian Embassy in London.

The conclusion enables both sides to claim a degree of satisfaction. The U.S. Justice Department, facing a defendant who had already served substantial jail time, was able to resolve -- without trial -- a case that raised thorny legal issues and that might never have reached a jury at all given the plodding pace of the extradition process.

Assange, for his part, signalled a begrudging contentment with the resolution, saying in court that though he believed the Espionage Act contradicted the First Amendment, he accepted the consequences of soliciting classified information from sources for publication.

Assange arrived at court in a dark suit, with a tie loosened around the collar, after flying from Britain on a charter plane accompanied by members of his legal team and Australian officials, including the top Australian diplomat in the U.K.

Inside the courthouse, he answered basic questions from U.S. District Judge Ramona Manglona, an appointee of former U.S. president Barack Obama, and appeared to listen intently. As a condition of his plea, he will be required to destroy information provided to WikiLeaks.

The secret-spilling website, which Assange founded in 2006, said in its own statement that it was grateful for "all who stood by us, fought for us, and remained utterly committed in the fight for his freedom."

Assange appeared upbeat and relaxed during the hearing, at times cracking jokes with the judge. While signing his plea agreement, he made a joke about the nine-hour time difference between the U.K. and Saipan. At another point, when the judge asked him whether he was satisfied with the plea conditions, Assange responded: “It might depend on the outcome,” sparking some laughter in the courtroom.

"So far, so good," the judge responded.

Julian Assange

The plea deal, disclosed Monday night in a sparsely detailed Justice Department letter, represents the latest -- and presumably final -- chapter in a court fight involving the eccentric Australian computer expert who has been celebrated by supporters as a transparency crusader but lambasted by national security hawks who insist that his disdain for government secrecy put lives at risks and strayed far beyond the bounds of traditional journalism duties.

The guilty plea resolves a criminal case brought by the Trump administration Justice Department in connection with the receipt and publication of war logs and diplomatic cables that detailed U.S. military wrongdoing in Iraq and Afghanistan.

Prosecutors alleged that he conspired with former army intelligence analyst Chelsea Manning to obtain the records and published them without regard to American national security, including by releasing the names of human sources who provided information to U.S. forces in Iraq and Afghanistan were among the details exposed, prosecutors have said.

But his activities drew an outpouring of support from press freedom advocates, who heralded his role in bringing to light military conduct that might otherwise have been concealed from view. Among the files published by WikiLeaks was a video of a 2007 Apache helicopter attack by American forces in Baghdad that killed 11 people, including two Reuters journalists.

The indictment was unsealed in 2019, but Assange's legal woes long predated the criminal case and continued well past it.

Weeks after the release of the largest document cache in 2010, a Swedish prosecutor issued an arrest warrant for Assange based on one woman's allegation of rape and another's allegation of molestation. Assange has long maintained his innocence, and the investigation was later dropped.

He presented himself in 2012 to the Ecuadorian Embassy in London, where he claimed asylum on the grounds of political persecution, and spent the following seven years in self-exile there, hosting a parade of celebrity visitors and making periodic appearances from the building's balcony to address supporters.

Julian Assange WikiLeaks X

In 2019, his hosts revoked his asylum, allowing British police to arrest him. He remained locked up for the last five years while the Justice Department sought to extradite him, in a process that encountered skepticism from British judges who worried about how Assange would be treated by the American criminal justice system.

Ultimately, though, the resolution sparing Assange prison time in the U.S. is a repudiation of sorts of years of ominous warnings by Assange and his supporters that the American criminal justice system would expose him to unduly harsh treatment, including potentially the death penalty -- something prosecutors never sought.

Last month, Assange won the right to appeal an extradition order after his lawyers argued that the U.S. government provided "blatantly inadequate" assurances that he would have the same free speech protections as an American citizen if extradited from Britain.

His wife, Stella Assange, told the BBC from Australia that it had been "touch and go" over 72 hours whether the deal would go ahead but she felt "elated" at the news. A lawyer who married the WikiLeaks founder in prison in 2022, she said details of the agreement would be made public once the judge had signed off on it.

"He will be a free man once it is signed off by a judge," she said, adding that she still didn't think it was real.

Assange on Monday left the London prison, where he has spent the last five years, after being granted bail during a secret hearing last week. He boarded a plane that landed hours later in Bangkok to refuel before taking off again toward Saipan. A video posted by WikiLeaks on X, showed Assange staring intently out the window at the blue sky as the plane headed toward the island.

"Imagine. From over 5 years in a small cell in a maximum security prison. Nearly 14 years detained in the U.K. To this," WikiLeaks wrote.

------

Tucker reported from Fort Pierce, Fla., and Durkin Richer from Washington. Associated Press writers Colleen Long in Washington, Napat Kongsawad and David Rising in Bangkok, Jill Lawless and Brian Melley in London and Rod McGuirk in Melbourne, Australia, contributed to this report.