The 21-year-old Kosovar Arid Uka carried out the attack on Wednesday "because he wanted to take revenge for the US intervention in Afghanistan," federal prosecutor Rainer Griesbaum told reporters.
The suspect has said that the day before the attack he watched a video on the internet purporting to show US atrocities in Afghanistan, Griesbaum said.
The shooter "saw a video on the internet portal YouTube the day before the act," Griesbaum said. "In this video, American soldiers apparently raided a Muslim house and raped the daughter of the family," he added.
"He could not get the pictures out of his head and wanted with his actions to prevent American soldiers going to Afghanistan and carrying out such acts," added the prosecutor.
Griesbaum also said there was no evidence to link Uka to any international extremist group like al-Qaida, German prosecutors said Friday.
"There is currently no evidence to suggest membership to an international terrorist organisation," he said.
Griesbaum said the gunman had 10 magazines with 14 bullets each plus two knives with him. He shot the first airman in the back of the head at point-blank range after asking him for a cigarette outside their bus and asking if he was being deployed to Afghanistan, the prosecutor said.
Uka then boarded the bus, cried "Allahu Akhbar" ("God is Great") and shot the driver in the head, killing him. He then shot two others before putting the gun to the head of another serviceman and pulling the trigger twice, Griesbaum said. But the gun jammed.
Uka then fled into the terminal building, but the serviceman whom he had just tried to kill followed him and apprehended him with help of German police.
The attack, if confirmed as such, was the first Islamic extremist attack on German soil. It also left two airmen seriously injured, one of them fighting for his life in a Frankfurt hospital. The other was in intensive care.
Late Thursday, the US Air Force identified the dead servicemen as Senior Airman Nicholas Alden, 25, of Williamston, South Carolina, and Airman First Class Zachary Cuddeback, 21, of Stanardsville, Virginia.