A criminal court in Morocco convicted a 31-year-old man Thursday of belonging to a terrorist group involved in the 2004 Madrid train bombings and sentenced him to 20 years in prison.

Prosecutors at the Sale criminal court, which specializes in terrorism cases, had requested that Abdelilah Ahriz be given a life sentence, saying witness testimony and DNA sampling proved Ahriz' involvement in preparing the simultaneous train bombings that killed 191 people.

At the end of the one-day trial Thursday, the court said in a public verdict it found Ahriz guilty of several terror-related charges, including "belonging to a criminal group that aimed to commit acts of terrorism" and collecting funds for terror groups.

An electrician, Ahriz had settled Spain in 1999 but left the country shortly after the bombings. He moved to Syria in 2005, where he was arrested and extradited.

He was tried in Sale, near the capital, Rabat, under a 1997 agreement between Spain and Morocco that allows the prosecution of a suspect in his native country for crimes committed abroad.

Ahriz was previously acquitted by a Moroccan court for his role in the Madrid bombings, but authorities arrested him again in June to try him on broader charges.

He denied all the accusations against him Thursday. His lawyer, Abdellatif Ennouari, told The Associated Press that he would appeal the sentence because it was too severe.

"I hope the appeals court will be fairer," he said, saying it was unlawful to prosecute his client twice on similar terrorism charges.

The Sale court said police had conducted new tests that confirmed that Ahriz's DNA matched samples found by Spanish authorities in two locations where the Madrid bombers blew themselves up to avoid arrest after the attacks.

His DNA was found on a comb in an apartment used by the terrorists in Leganes, near Madrid, and on a pair of bloodstained pants at a country house in Morata de Tajuna, outside the capital, the court said.

The Madrid attacks were among Europe's worst ever and injured more than 1,800 people. Most of the suspected bombers were Moroccans, several of whom are serving lengthy sentences in Spain.