WikiLeaks founder Julian Assange pleaded guilty Tuesday in connection with a deal with federal prosecutors to close a drawn-out legal saga related to the leaking of military secrets that raised divisive questions about press freedom, national security and the traditional bounds of journalism.

The plea to a single count of conspiring to obtain and disclose information related to the national defense was entered Wednesday morning in federal court in Saipan, the capital of the Northern Mariana Islands, an American territory in the Pacific.

Julian Assange in court

WikiLeaks founder Julian Assange, second from right, arrives at the United States courthouse where he is expected to enter a plea deal in Saipan, Mariana Islands, Wednesday, June 26, 2024. (AP Photo/Eugene Hoshiko) (AP )

Assange said that he believed that the Espionage Act under which he was charged contradicted his First Amendment rights but that he accepted that encouraging sources to provide classified information for publication can be unlawful.

"I believe the First Amendment and the Espionage Act are in contradiction with each other but I accept that it would be difficult to win such a case given all these circumstances," he reportedly said in court. 

Under the terms of the deal, Assange is permitted to return to his native Australia without spending any time in an American prison. He had been jailed in the United Kingdom for the last five years, while fighting extradition to the United States.

A conviction could have resulted in a lengthy prison sentence. 

AUSTRALIAN LAWMAKERS SEND LETTER URGING BIDEN TO DROP CASE AGAINST JULIAN ASSANGE ON WORLD PRESS FREEDOM DAY

Julian Assange after being released from prison

Screen grab taken from the X account of WikiLeaks founder Julian Assange following his release from prison on Tuesday June 25, 2024. Assange has arrived in Saipan ahead of an expected guilty plea in a deal with the U.S. Justice Department that will set him free to return home to Australia. (@WikiLeaks, via AP)

WikiLeaks, the secret-spilling website that Assange founded in 2006, applauded the announcement of the deal, saying it was grateful for "all who stood by us, fought for us, and remained utterly committed in the fight for his freedom."

Federal prosecutors said Assange conspired with Chelsea Manning, then a U.S. Army intelligence analyst, to steal diplomatic cables and military files published in 2010 by WikiLeaks. Prosecutors had accused Assange of damaging national security by publishing documents that harmed the U.S. and its allies and aided its adversaries.

Manning was sentenced to 35 years in prison. President Barack Obama commuted the sentence in 2017 in the final days of his presidency.

Assange has been celebrated by free press advocates as a transparency crusader but heavily criticized by national security hawks who say he put lives at risk and operated far beyond the bounds of journalism.  

SUPPORTERS OF JULIAN ASSANGE RALLY AT JUSTICE DEPT. ON 4-YEAR ANNIVERSARY OF DETAINMENT

Julian Assange boarding a plane

Julian Assange seen boarding an airplane. (Getty Images)

Weeks after the 2010 document cache, Swedish prosecutors issued an arrest warrant for Assange for allegedly raping a woman and an allegation of molestation. The case was later dropped. Assange has always maintained his innocence. 

In 2012, he took refuge in 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. 

CLICK HERE TO GET THE FOX NEWS APP

The Ecuadorian government in 2019 allowed the British police to arrest Assange and he remained in custody for the next five years while fighting extradition to the U.S. 

The Associated Press contributed to this report.