Arid Uka, who admits killing two US airmen, talks to lawyer Michaela Roth before the trial began in Frankfurt on Wednesday. Photograph: Alex Domanski/Reuters

A 21-year-old Kosovan Albanian confessed on Wednesday to killing two US airmen at Frankfurt airport, saying in emotional testimony at the opening of his trial that he had been influenced by Islamist propaganda online.

Arid Uka is charged with two counts of murder for killing Nicholas J Alden, 25, from South Carolina, and Zachary R Cuddeback, 21, from Virginia on 2 March this year. He also faces three counts of attempted murder in connection with the wounding of two others.

Although Germany has suffered scores of terrorist attacks, largely from leftwing groups such as the Red Army Faction, the airport attack was the first attributed to an Islamic extremist.

Since the September 11 2001 attacks there have been about a half-dozen other jihadist plots that were either thwarted or failed, including a plan to kill Americans at the US air force's Ramstein base in 2007.

Prosecutor Herbert Deimer told a state court in Frankfurt that Uka went to the airport with the intent "to kill an indeterminate number of American soldiers, but if possible a large number".

No pleas are entered in the German system and Uka confessed to the killings after the indictment was read, telling the court: "What I did was wrong but I cannot undo what I did."

He went on to urge other radical Muslims not to seek inspiration in his attack, urging them not to be taken in by "lying propaganda" on the internet. "To this day I try to understand what happened and why I did it ... but I don't understand."

Uka described becoming increasingly introverted in the months before the attack, staying at home and playing computer games and watching Islamist propaganda on the internet.

The night before the crime, he said he followed a link to a video posted on Facebook that purported to show American soldiers raping a teenage Muslim girl. It turned out to be a scene from Redacted, the 2007 anti-war film by Brian De Palma, taken out of context.

He said he then decided he should do anything possible to prevent more American soldiers from going to Afghanistan. "I thought what I saw in that video these people would do in Afghanistan," he told the court, his voice choking with emotion as he wiped away tears.

Uka conceded when asked by prosecutor Jochen Weingarten that the airman driving the bus had not been going to Afghanistan.

On the bus on the way to the airport to look for victims, he said he listened to Islamic music on his iPod while nursing doubts that would be able to follow through with his plan. "On the one hand I wanted to do something to help the women, and on the other hand I hoped I would not see any soldiers," he told the court.

Six months later, he says he does not understand why he went through with the killings. "If you ask me why I did this I can only say ... I don't understand anymore how I went that far."

The indictment says Uka went to the airport armed with a pistol, extra ammunition and two knives. Inside Terminal 2, he spotted two US servicemen who had just arrived and followed them to their US air force bus.

Sixteen servicemen, including the driver, were on or near the bus. Uka approached one of the men for a cigarette, prosecutors said. He confirmed they were US air force members en route to Afghanistan, then "turned around, put the magazine that had been concealed in his backpack into his pistol, and cocked the weapon", the indictment read.

He first shot unarmed Alden in the back of the head, the indictment alleged. He then boarded the vehicle shouting "Allahu Akbar" – Arabic for "God is great" – and shot and killed Cuddeback, who was the driver, before firing at others.

He wounded two others – one victim has lost sight in one eye permanently – before his gun jammed and he fled, prosecutors said. Uka was then chased and caught.

Some of the American airmen are expected to testify at the trial. At least one relative of the victims – Cuddeback's mother – has joined the trial as a co-plaintiff.