The regional superior court in the western city convicted Yusef Mohammed al-Hajj Dib, 24, of multiple counts of attempted murder for his part in an attempt to attack two regional trains packed with travellers in July 2006.
A life sentence in Germany generally amounts to 15 years in prison. Dib's attorney said he would appeal the verdict.
Men identified by police as Dib and a Lebanese associate, Jihad Hamad, were captured on security cameras at Cologne rail station placing suitcases packed with homemade explosives on two trains carrying 280 people on July 31, 2006.
The images ran in heavy rotation on national television as the country digested how close it had come to the first Islamic extremist attack on German soil following the September 11, 2001, attacks in the United States which were planned in part in the German port city of Hamburg.
"The prosecution was right in noting that Germany was never closer to an Islamist attack than in this case," presiding judge Ottmar Breidling said, noting that Dib had taken Al-Qaeda masterminds Osama bin Laden and the late Abu Musab al-Zarqawi as his idols.
"The fact that it did not come to a devastating bloodbath with several dead is only thanks to mistakes made by the accused and his accomplice, Jihad Hamad, in building the bombs."
Dib, dressed in a beige hooded sweatshirt, sat impassively in the high-security courtroom as Breidling read the verdict but earlier made an obscene hand gesture at press photographers as they snapped shots of him in the dock.
Prosecutors argued that the explosions could have killed up to 75 people, saying only a technical fault prevented a massacre in a plot modelled on the deadly train blasts in Madrid in 2004 and London the following year.
Breidling said Dib was guilty of a "thoroughly terrorist act" and dismissed his claim that he had only placed a mock-up of a bomb in a rail carriage to scare the German public. He said the court did not believe that botching the operation was a mitigating factor, arguing the defendant had "committed a crime for which only the highest penalty under the law can apply."
A successful bombing could have lead to a "bloodbath of monstrous proportions," he added.
Dib had told the court during his year-long trial that he only intended to frighten Germans in revenge for the publication of caricatures of the Prophet Mohammed in Europe, which sparked protests by Muslims around the world. His defence lawyer Bernd Rosenkranz told the court that Dib had made a conscious decision not to include oxygen in the homemade bombs -- the missing ingredient necessary to trigger an explosion.
The attempted bombings came just weeks after the World Cup football championship in Germany during which hundreds of thousands of fans from around the world descended on the country.
Both Dib and Hamad, who is serving a 12-year sentence in Beirut over the plot, had been living as students in Germany. After putting the suitcases on the trains, they each disembarked at the next station and flew from Cologne to Istanbul and then Lebanon, where Hamad was captured.
Dib was arrested after he returned to Germany days later. When Hamad was convicted in Lebanon, the same court sentenced Dib to life in absentia. Information provided by Hamad, 22, during interrogation was key to Dib's prosecution in Germany.
German authorities regularly warn that Islamic militants have the country in their sights. Hans-Georg Engelke, head of the Islamist terrorist division at the domestic intelligence office, told a colloquium in Berlin Monday that Germany could fall victim to an attack "at any moment."
In September 2007, German police in the southwest of the country smashed what they said was a terrorist cell planning imminent attacks against US interests in Germany.