Barack Obama commuted her sentence before he left office.

US soldier Chelsea Manning has been released from prison after seven years for leaking thousands of diplomatic and military files to Wikileaks.

Marking the occasion, she tweeted, saying "first steps of freedom" with a picture of her feet leaving the prison.

"She's ready to finally be able to live as the woman that she is," her attorney Nancy Hollander told the BBC. The 29-year-old soldier was born Bradley Manning.

Shortly after she was sentenced to 35 years in prison in 2013, Manning said she had felt female since childhood and wanted to live as a woman called Chelsea.

Ahead of her release she said: 'I'm looking forward to breathing the warm spring air again.

"I want that indescribable feeling of connection with people and nature again, without razor wire or a visitation booth. I want to be able to hug my family and friends again. And swimming – I want to go swimming."

Manning is expected to live in Maryland, the same state where she sent WikiLeaks the classified military and diplomatic documents that landed her in prison.

The 29-year-old had served seven years of a 35-year stretch when Barack Obama commuted her sentence right before he left the White House.

Manning was deployed to Iraq as an intelligence analyst when she leaked hundreds of thousands of files to Wikileaks.

Manning twice attempted suicide last year at Fort Leavenworth, a male military prison. She also went on a hunger strike last year, which she ended after the military agreed to provide her with gender transition treatment.