WikiLeaks founder Julian Assange is due to plead guilty on Wednesday to violating U.S. espionage law, in a deal that will set him free after a 14-year British legal odyssey and allow his return home to Australia.

Assange, 52, has agreed to plead guilty to a single criminal count of conspiring to obtain and disclose classified U.S. national defense documents, according to filings in the U.S. District Court for the Northern Mariana Islands.

The deal marks the end of a legal saga that has seen Assange spend more than five years in a British high-security prison and seven holed up in the Ecuadorean Embassy in London as he fought accusations of sex crimes in Sweden and battled extradition to the U.S., where he faced 18 criminal charges.