Media playback is unsupported on your device Media caption Obama defends decision to free Manning

President Barack Obama has defended his decision to free Wikileaks source Chelsea Manning, 29 years before her scheduled release.

He told his final news conference that "justice has been served".

Manning was sentenced to 35 years for leaking diplomatic cables to the group, one of the largest breaches of classified material in US history.

The commutation of her sentence has been attacked by Republicans as sending the wrong message.

Media playback is unsupported on your device Media caption Obama's advice to Trump: 'Reality has a way of biting back'

House Speaker Paul Ryan said the move set a "dangerous precedent".

The 29-year-old transgender US Army private, born Bradley Manning, leaked documents to Wikileaks in 2010.

She will be freed on 17 May but had been scheduled to be released in 2045.

Farewell Obama

Media playback is unsupported on your device Media caption Barack Obama supporters on how they think he succeeded, and where he could have done more

Five times Obama went viral

Did he improve US race relations?

Obama's biggest regrets

Presidential photographer's favourite pics

The president said Manning has served a tough prison sentence.

"So the notion that the average person who was thinking about disclosing vital, classified information would think that it goes unpunished - I don't think they would get that impression from the sentence that Chelsea Manning has served."

The commutation announced on Tuesday reduces Manning's sentence but is not a pardon, which some campaigners had called for.

Image copyright Reuters Image caption Chelsea Manning, then Bradley, was convicted in 2013

Senator John McCain, chairman of the Senate Armed Services Committee, called it a "grave mistake" because Manning endangered lives.

"Her prison sentence may end in a few months' time, but her dishonour will last forever," he said.

Mr Ryan said President Obama "now leaves in place a dangerous precedent that those who compromise our national security won't be held accountable for their crimes".

White House press secretary Josh Earnest hit back at Republican criticism, suggesting the party was being hypocritical given President-elect Donald Trump has praised Wikileaks.

The group released hacked Democratic Party emails during the election campaign.

"It is outrageous for them to suggest that right now what Chelsea Manning did is worse than what the man who they endorsed for president did," he told CBS News.

He also told CNN that Mr Obama believed Manning had served an "appropriate punishment", having been jailed for nearly seven years.

More on Chelsea Manning

Media playback is unsupported on your device Media caption Who is Chelsea Manning?

Most people convicted of leaking have received sentences of between one and three years, according to the New York Times. The Obama administration has prosecuted more people for leaking government secrets than were charged under all previous presidencies, the paper says.

Manning twice attempted suicide last year at the male military prison where she is being held at Fort Leavenworth, Kansas.

She also went on a hunger strike last year, which she ended after the military agreed to provide her with gender transition treatment.

Mr Obama granted commutation of sentences to 209 individuals and pardons to 64 others, in one of his final acts as president.

Why is the decision so controversial?

Image caption Leaked footage among files leaked by Chelsea Manning showed a US helicopter pilot killing civilians and journalists in Baghdad in 2007

Critics argue that Manning's decision to leak a massive trove of documents to Wikileaks - including 250,000 diplomatic cables and more than 450,000 reports from the wars in Iraq and Afghanistan - endangered US troops, intelligence agents and diplomats, in addition to foreigners who had helped them in hotspots abroad.

By uploading the material online, they say that the documents were made available to everyone, including Al-Qaeda. They also caused major embarrassment to the United States.

Chelsea Manning been characterised as a traitor, even though she said she believed the leaked material would "spark a domestic debate".

Why did Obama act to help Manning, but not Edward Snowden?

Edward Snowden, a former National Security Agency (NSA) contractor, leaked documents revealing extensive internet and phone surveillance by US intelligence, sparking a global debate on internet privacy.

Russian authorities said on Wednesday that Mr Snowden had been granted a two-year extension to his temporary asylum in the country.

More than a million people have signed a petition asking for him to also receive some sort of clemency from President Obama.

But the White House has poured cold water on any hopes that he might be next. Mr Earnest said that in comparison to Mr Snowden, Chelsea Manning went "through the military criminal justice process, was exposed to due process, was found guilty, was sentenced for her crimes, and she acknowledged wrongdoing."

Image copyright EPA Image caption Edward Snowden fled the US in 2013, evading charges that could see him imprisoned for up to 30 years

Mr Snowden, Mr Earnest said, "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."

He also said the NSA leaker had not filed the paperwork required to seek clemency, and, in any case, Mr Snowden's leaks were said to be "far more serious and far more dangerous" than Manning's.

Media playback is unsupported on your device Media caption Journalist Glenn Greenwald: Chelsea Manning and Edward Snowden "acted with extreme amounts of courage"

What do his supporters say to that?

They argue that what he revealed - and the impact it had - has improved American democracy.

"Thanks to Edward Snowden's act of conscience, we have made historic strides in our fight for surveillance reform and improved cyber security," American Civil Liberties Union executive director Anthony Romero has said.

Human Rights Watch says that the Espionage Act is "a First World War-era law that does not distinguish between selling secrets to foreign governments and giving them to journalists working in the public interest".

Pardoning Snowden, they say, would encourage other whistleblowers to step forward without fear.