Pte First Class Bradley Manning, 25, was convicted in July of 20 charges against him, including espionage.
Last week, he apologized for hurting the US and for “the unexpected results” of his actions.
Prosecutors had asked for a 60-year sentence in order to send a message to future potential leakers.
Bradley Manning will receive a credit against his sentence of about three and a half years, including time he has already served in jail and 112 days in recompense for the harsh conditions of his initial confinement.
He could be eligible for parole in about 11 years.
On Twitter, WikiLeaks called the sentence a “significant strategic victory”.
In the military courtroom in Fort Meade, Maryland, on Wednesday, Judge Col Denise Lind declared Pte Bradley Manning would be demoted to private and dishonorably discharged from the US Army, and forfeit his pay.
While stationed in Iraq in 2010, the junior intelligence analyst passed hundreds of thousands of battlefield reports and diplomatic cables to WikiLeaks, the pro-transparency group headed by Julian Assange.
Bradley Manning has said he leaked the secret files in the hopes of sparking a public debate about US foreign policy and the military.
In a statement during the sentencing hearing, Bradley Manning told the court martial at Fort Meade, Maryland that “the last three years have been a learning experience for me”.
He said he mistakenly believed he could change the world for the better, and that in retrospect, he should have worked “inside the system”.
His defense lawyers are expected to make a statement later on Wednesday.
The verdict and sentence will be reviewed, and possibly reduced, by a military district commander and will be automatically reviewed by the Army Court of Criminal Appeals.
Bradley Manning may also petition the court for lenience during the appeals process.
He is expected to serve his sentence at Fort Leavenworth, Kansas.
Meanwhile, Amnesty International and the Bradley Manning Support Network have announced an online petition asking President Barack Obama to pardon Pte Manning.
The young soldier grew up in Oklahoma and in Wales, where his mother is from, and reportedly joined the US Army to help pay for college.
As an intelligence analyst, Bradley Manning had access to a large amount of very sensitive information, despite his junior rank. He deployed to Iraq in 2009.
A military psychiatrist testified that Bradley Manning had struggled with his gender identity and wanted to become a woman at the time of the leak.
Navy Capt. David Moulton testified that Bradley Manning had felt abandoned by friends and family and that his relationship with his boyfriend had hit a rough patch.
According to evidence presented by the defense, military supervisors ignored Bradley Manning’s erratic behavior, which included trying to grab a gun during a counseling session.
His lawyers said such actions had shown that Bradley Manning had not been fit for duty overseas.
Defense lawyers said Bradley Manning was treated unfairly in solitary confinement in Quantico, Virginia and in a cell at Camp Arifjan, a US Army installation in Kuwait.
Bradley Manning told the court he remembered thinking: “I’m going to die, I’m stuck inside this cage.”
The leaks enabled WikiLeaks to publish sensitive messages between US diplomats and records of military incidents in the wars in Iraq and Afghanistan, as well as a cockpit video showing a US Apache helicopter killing 12 people in the Iraqi capital in 2007.
The revelations caused significant embarrassment to the US government, and US officials have said the disclosures damaged US relations with its allies and disrupted the war effort in Afghanistan.
xS9JT6n483IThe US House Ethics Committee has voted to release its report on former Republican Representative…
ABC News has agreed to pay $15 million to President-elect Donald Trump to settle a…
South Korea’s parliament has voted to impeach President Yoon Suk Yeol over his failed attempt…
Israeli war planes have carried out more than 100 air strikes in Syria on December…
President-elect Donald Trump has threatened to impose 100% tariffs on the BRICS countries if they…
Syrian troops have withdrawn from the city of Aleppo following an offensive by rebels opposed…