With only three days left in office, President Barack Obama on Tuesday commuted the majority of WikiLeaks whistleblower Chelsea Manning's prison sentence.

Manning was convicted of violating the Espionage Act, among other charges, in 2013 after she stole secret documents from a computer system she had access to while working as an intelligence analyst in Iraq and leaked them to WikiLeaks in 2010.

She received a 35-year sentence for the leak and has served seven years in Fort Leavenworth. She will now be freed in five months, on May 17.

Manning, a transgender woman, has attempted suicide twice while in prison.

Julian Assange, the founder of WikiLeaks, said last week that he'd agree to be extradited to the US if Obama granted clemency to Manning.

The US has threatened to prosecute Assange over the 2010 leak. Assange has been holed up at the Ecuadorian Embassy in London since 2012 to avoid extradition to Sweden, where he has been accused of sexual assault.

Chelsea Manning. AP

Josh Earnest, the White House press secretary, told The New York Times on Tuesday that there was a "pretty stark difference" between Manning's case and that of former government employee Edward Snowden, the other recent high-profile US leaker, who has taken asylum in Russia.

"Chelsea Manning is somebody who went through the military criminal justice process, was exposed to due process, was found guilty, was sentenced for her crimes, and she acknowledged wrongdoing," Earnest said. "Mr. Snowden fled into the arms of an adversary, and has sought refuge in a country that most recently made a concerted effort to undermine confidence in our democracy."

Snowden declared his support for Manning on Twitter.

"In five more months, you will be free," Snowden tweeted. "Thank you for what you did for everyone, Chelsea. Stay strong a while longer!"

Obama pardoned 64 other people on Tuesday and shortened the sentences of 209 prisoners — Snowden was not among them. Over his two terms, Obama has commuted the sentences of 1,385 people and granted 212 pardons.