During his final days in office, US President Barack Obama commuted the sentence of Chelsea Manning, who was found guilty of leaking US army documents. She will be freed on Wednesday.
The US soldier then known as Pte First Class Bradley Manning lip-synced to Lady Gaga while downloading thousands of classified documents from military servers, according to a computer hacker she befriended.
The 29-year-old is six years into what would have been a 35-year sentence, after being convicted of 20 charges in connection with the leaks, including espionage. She was acquitted of the most serious charge, aiding the enemy.
After her sentencing, Pte Manning, who was born a man, said she wanted to live as a woman and had taken the name Chelsea.
Her time in prison has seen her engage in a fight with the army over receiving gender reassignment surgery, a fight that also saw her attempt to take her own life.
In November, she urged then-President Obama to reduce the remainder of her sentence to the six years she has already served. She said she took "full and complete responsibility" for her actions, and was not asking for a pardon.
Three days before he left office, he granted her wish.
'Funny little character'
As an intelligence analyst in the US Army, Pte Manning was given access to a large amount of highly sensitive information.
But as a private first class, she was very low-ranking with a relatively meagre wage.
According to her friends, she had become frustrated with a military career that appeared to be stagnating.
And her personal life appears to have hit a downward spiral after she was posted to Iraq in 2009.
Pte Manning joined the army in 2007 after drifting through low-paid jobs.
Born in December 1987, she was brought up in Crescent, a small town in Oklahoma. Her father, Brian, reportedly spent five years in the military.
But her parents divorced when she was a teenager, and she moved with her mother to Haverfordwest in south-west Wales.
As a teenager, she was said to have been a hothead who was often teased for being a geek.
A friend from Wales, James Kirkpatrick, told the BBC she was a "funny little character, really on the ball" who was obsessed with computers.
After finishing school, she returned to the US and joined the army. Friends say she enlisted to help pay for college, and she later said she had joined up in the hope the army would rid her of her desire to be a woman.
She was deployed to Iraq in October 2009. But messages she posted on Facebook suggest she was far from happy.
She wrote in early May 2010 on the site that she was "beyond frustrated with people and society at large".
A week earlier, she had written: "Bradley Manning is now left with the sinking feeling that he doesn't have anything left."
Some of the postings appear to refer to a recent breakdown of a relationship.
But weeks later her words appeared prophetic when she was arrested by military investigators on suspicion of stealing secret information.
Self-confessed computer hacker Adrian Lamo told the world's media how Pte Manning had admitted the data theft during conversations they had on the internet.
"Listened and lip-synced to Lady Gaga's Telephone while exfiltrating possibly the largest data spillage in American history," Pte Manning wrote, according to a transcript of their messages published on Wired's website.
"Weak servers, weak logging, weak physical security, weak counter-intelligence, inattentive signal analysis… a perfect storm."
Mr Lamo went to the authorities with the messages.
During a sentencing hearing at her court martial in August 2013, a military psychiatrist testified that Pte Manning had struggled with her gender identity and wanted to become a woman.
In March 2011, the US Army charged Pte Manning with 22 counts relating to the unauthorised possession and distribution of more than 720,000 secret diplomatic and military documents.
Among the files she passed to Wikileaks was video footage of an Apache helicopter killing 12 civilians in Baghdad in 2007.
Wikileaks released tens of thousands of documents relating to the Afghan war.
The website later disclosed thousands of sensitive messages written by US diplomats and military records from the Iraq war, causing growing embarrassment to the US government.
Pte Manning told the court she had leaked the documents to spark a public debate in the US about the role of the military and about US foreign policy.
At a later sentencing hearing, she apologised for "hurting the US" and said she had mistakenly believed she could "change the world for the better".
'I am Chelsea Manning'
A day after she was sentenced to 35 years in prison, Pte Manning said she wanted to live as a woman.
"I am Chelsea Manning," she said in statement to NBC's Today programme. "I am a female."
She said she had felt female since childhood, wanted at once to begin hormone therapy, and wished to be addressed as Chelsea.
In 2014, a military judge granted Manning's official name change from "Bradley Edward Manning" to "Chelsea Elizabeth Manning" and she was later approved for hormone therapy .
She tried twice to take her own life during her time at Leavenworth prison in Kansas. It was later reported this was because of her ongoing fight for gender reassignment surgery.
Her lawyer also said she had spent long stretches in solitary confinement.
In 2016, she went on hunger strike, before bringing it to an end after the army agreed to provide her with the surgery.
During her time in prison, the US Department of Defense lifted a longstanding ban against transgender men and women serving openly in the military.
Manning is expected to complete her gender transition after her release.