The Moroccan gunman on trial for an attempted terror attack on a Paris-bound train five years ago said Wednesday he had aimed at the heads of American soldiers but could not shoot.

On August 21, 2015, after drinking a coffee at the station in Brussels, Ayoub El Khazzani told the court that he boarded the Amsterdam-Paris high-speed Thalys train concealing an AK-47 automatic rifle and 300 rounds of ammunition.

Speaking at his trial for the first time, he said he was under orders from Abdelhamid Abaaoud, who had travelled with him to Europe from war-torn Syria to guide the cell behind the deadly attacks in November 2015 in Paris and in March 2016 in the Belgian capital Brussels.

"I took my seat. I started looking for the people he had spoken to me about, American soldiers, people from the European Commission. Honestly it was to kill them," the 31-year-old Khazzani told the court.

He said he eventually located his American targets.

he presiding judge asked him: "How did you recognise them?"

"Abaaoud had told me they were young and burly, that they spoke English," Khazzani replied.

"I decided to attack the American soldiers," the defendant said through an interpreter.

He said he went to the toilet to prepare the attack but that he was in a bad state.

Nevertheless, he took his pistol and Kalashnikov rifle out of his bag took and armed himself, he said.

"I was trembling," he recalled.

From left to right in the dock are gunman Ayoub El Khazzani and co-accused Mohamed Bakkali, Bilal Chatra and Redouane El Amrani Ezzerrifi.
From left to right in the dock are gunman Ayoub El Khazzani and co-accused Mohamed Bakkali, Bilal Chatra and Redouane El Amrani Ezzerrifi. AFP / Elisabeth De Pourquery

When he emerged from the toilet, he ran into passenger Mark Moogalian and ended up shooting him in the back with his pistol when the English professor grabbed his Kalashnikov.

"I aimed at his hand," he said.

In the courtroom's first row, Moogalian, seriously wounded in the attack, listened with his head lowered and his hand holding his wife's.

Khazzani said he then saw Spencer Stone, a US Air Force serviceman who was on vacation with friends.

"I aimed at his head... I could not do it. I cannot explain to you. It was too much....I let him grab me," he said.

The prosecution argues that Khazzani failed to carry out a massacre on the train because of defective munitions and passengers who intervened to subdue him.

Testifying last week, Aleksander Skarlatos, a former national guardsman and Stone's friend, told the court he understood immediately what was happening when he heard a gun shot and knew they could have died that day.

The pair decided to go after the gunman. Stone eventually caught him and rolled on the ground with Khazzani, at one point warning that the attacker had a pistol, which Skarlatos said he grabbed.

Khazzani, who joined the Islamic State group in Syria in May 2015, is charged with "attempted terrorist murder".

In the dock with him are three men facing charges for aiding and abetting the crime: Bilal Chatra, Redouane Sebbar and Mohamed Bakkali.

Belgian Abaaoud, who Khazzani named as the operation chief, is believed to have been one of the masterminds behind several attacks in Europe.

French police killed Abaaoud after he shot indiscriminately at packed cafe terraces in Paris on the night of the November 2013 coordinated attacks, for which Bakkali is also accused of having acted as logistics coordinator.