The men were known as the "Sauerland group" after the area of western Germany where they were caught.
Police had been watching their rented holiday cottage for several months before swooping in to make the arrests.
Judge Ottmar Breidling, speaking at the conclusion of the 10-month trial, said the men aimed to kill at least 150 US soldiers stationed in Germany.
"You were planning a monstrous bloodbath that would have killed an unfathomable number of people," Breidling said.
"Never before had there been a terror attack of that dimension in Germany.
"You were blinded by a strange, hate-filled notion of jihad and you turned yourselves into angels of death in the name of Islam."
Breidling sentenced Fritz Gelowicz, the group's ringleader, to 12 years in jail.
He also handed Daniel Schneider a 12-year sentence because he fired at a police officer during an escape attempt.
Both men were converts to Islam.
The court also sentenced Adem Yilmaz, a Turkish citizen, to 11 years and Atilla Selek, a German citizen of Turkish origin, to five years.
The four men, who were members of the radical Islamic Jihad Union, had identified discos and airports, as well as the US Ramstein air base, as possible targets.
Prosecutors had sought terms of between five and a half to 13 years.
Breidling said their confessions and their co-operation with prosecutors had reduced their prison sentences.
"The confessions have provided an extraordinary glimpse into the structures of Islamic terrorism," the judge said.
The CIA helped to foil the plot after months of close co-operation with German authorities, German media reported.
About 600 German investigators had started monitoring the group in early 2007, before arresting them on September 4 that year.