"I want to apologize to everyone," Arid Uka told the court in Frankfurt, western Germany, on the first day of his murder trial.
"On March 2, I killed two people and opened fire on three others. Today I can't understand myself how I could have acted this way," he said.
Uka opened fire on a group of US soldiers at Frankfurt airport as they were on their way to join US forces in Afghanistan. Two airmen were killed and two wounded.
"The investigation showed that the accused wanted to kill the soldiers because they belonged to US forces under the ISAF mandate in Afghanistan," according to federal prosecutors referring to the NATO-led operation.
Uka, who faces a possible life sentence for murder and attempted murder, was arrested at the scene.
Prosecutors believe Uka, who was born in Mitrovica in northern Kosovo but who grew up in Frankfurt, acted alone and did not belong to a terrorist network.
Dressed in a white shirt and jeans, Uka told the court he had taken neither drugs nor alcohol on the day of the attack. Speaking in a low voice, he admitted to going to the airport with a 9 mm pistol and two knives.
"It was total idiocy and in contradiction with my (religious) beliefs," he said.
"No one should think of imitating me," he said, adding that he was influenced by "lies" and "propaganda" after seeing a video on the internet which alleged that US soldiers in Afghanistan had raped an Afghan woman.
Prosecutors say he told investigators it was on the morning of the attack that he decided to go out and kill as many US soldiers as possible in revenge. The propaganda video used extracts from the film "Redacted", a 2007 fictional drama by Brian De Palma.
"After seeing the video showing a raped Afghan woman, I was shocked, like paralysed," he said. "I tried to rid myself of the picture by praying. Come morning I was completely overwrought and worn out," he added.
He said he then caught a bus to the aiport where he had worked in a parcel sorting centre. He took along a pistol, ammunition and two knives in a backpack.
Prosecutors say he picked out a group of US soldiers who had just flown in from Britain and who were about to travel by bus to the nearby US airbase at Ramstein. Many troops take military transport there to Iraq or Afghanistan.
Uka is said to have bummed a cigarette from one of the soldiers and asked if they were on their way to Afghanistan. Prosecutors say that when the American said yes, he loaded his pistol and followed the men towards a waiting army bus.
At point-blank range, he is said to have fired into the back of the head of a 25-year-old soldier who died shortly afterwards.
Shouting "Allahu Akbar" (God is great), he then rushed onto the bus and shot dead the 21-year-old bus driver before opening fire on two more soldiers, aged 21 and 25, who were both seriously wounded, prosecutors say.
He is believed to have taken aim at another man cowering behind a seat, but his pistol misfired and he ran off into the airport terminal, pursued by another soldier. Police arrested him shortly afterwards.
The shootings have been called the first jihadist attack in Germany. In 1986, a bomb in a West Berlin nightclub blamed on Libya killed two US soldiers.
The September 11, 2001 attacks on the United States were planned in part in Hamburg by an al-Qaida cell led by the hijackers' ringleader, and in 2007 police thwarted a major plot to attack US soldiers and and civilians in Germany.
The trial is expected to last 10 days, with a verdict handed down early next year.