Teixeira, 22, was sentenced by US District Judge Indira Talwani in Boston after pleading guilty in March to perpetrating what federal prosecutors have called "one of the most significant and consequential violations" of US anti-espionage law ever committed.
He apologised in court for his actions.
"I'm sorry for all of the harm that I've brought and that I've caused," Teixeira, dressed in an orange jail uniform, told Talwani during his sentencing hearing on Tuesday.
The judge said that despite extensive training on how to handle classified documents and warnings about the penalties for disclosing them, Teixeira "posted on the internet, on Discord, hundreds of documents over a period of a year".
"The fact that others did not do more to stop you is truly unfortunate," she told Teixeira.
Teixeira, who has remained in custody since his arrest in April 2023, pleaded guilty to six counts of wilful retention and transmission of classified information relating to national defence over a leak in 2023 of a trove of classified records to a group of gamers on the Discord messaging app.
Before his sentencing, Teixeira also agreed to resolve separate military charges brought by the air force that he obstructed justice and failed to obey a lawful order, defence lawyer Michael Bachrach said in court.
The air force declined to confirm a deal had been reached, while noting Teixeira currently faces a court-martial in March.
Before his arrest, Teixeira had been an airman first class at Otis Air National Guard Base on Cape Cod in Massachusetts, where he worked as a cyber defence operations journeyman, or information technology support specialist.
Despite being a low-level airman, Teixeira held a top-secret security clearance.
Starting in January 2022, he began accessing hundreds of classified documents related to topics including Russia's invasion of Ukraine, according to prosecutors.
Teixeira shared classified information on Discord in private servers while bragging that he had access to "stuff for Israel, Palestine, Syria, Iran and China", according to prosecutors.
He did so even though his superiors admonished him twice in 2022 about his handling of classified information and warned him against conducting deep dives into intelligence information, prosecutors said.
His leaks included information concerning the US provision of equipment to Ukraine and how it would be used, following Russia's 2022 invasion.
Prosecutors pushed for nearly 17 years in prison, while Teixeira's lawyers urged an 11-year term.
They said Teixeira was autistic and isolated, and his intent was never to harm the United States but to educate friends he made online about world events, including the Ukraine war.
"He naively believed he could trust his friends," Bachrach said.
In December, the US Air Force announced it had moved to discipline 15 personnel over the leak and relieved Colonel Sean Riley of the command of the unit to which Teixeira belonged.