MADRID, Spain (CNN) -- A Spanish court Wednesday delivered an unexpectedly mixed verdict in the trial of 28 defendants charged in the 2004 Madrid train bombings, convicting three of mass murder but delivering lesser convictions against the others.
The three-judge panel delivered the verdict as most of the defendants watched from wooden benches in a glass-enclosed area of the courtroom.
Of the 28 men on trial, eight had been considered prime defendants, alleged to be either the bombers, ideologues, or "necessary cooperators" in the fatal plot. Each of the eight faced 191 charges of mass murder and more than 1,800 charges of attempted murder.
But there were gasps in the courtroom as the judges convicted only three of the eight prime defendants of the gravest charge -- mass murder. The judges convicted four others on lesser charges and acquitted one prime defendant of all charges.
The number of acquittals is likely to disappoint survivors of the attacks and relatives of the victims, who said the trial had dredged up bad memories of the bombings that they could not now put to rest. As they left court, some victims and families said they felt deprived of justice. Watch how victims of the bombings are coping
But The Associated Press quoted Prime Minister Jose Luis Rodriguez Zapatero, who was elected only days after the bombings, as saying: "Justice was rendered today. The barbarism perpetrated on March 11, 2004, has left a deep imprint of pain on our collective memory, an imprint that stays with us as a homage to the victims."
Fernando Reinares, a terrorism analyst from the Elcano Royal Institute in Madrid, said he was surprised that there were so many acquittals.
"In my opinion, we have enough evidence -- the police and judicial investigators provided enough evidence -- for them to be actually found guilty," Reinares told CNN.
The coordinated train bombings struck the morning of March 11, 2004, at Atocha station in central Madrid. They were the deadliest terrorist attacks in Western Europe since al Qaeda became active.
Prosecutors said the defendants were Islamic terrorists who were based in Spain but were inspired by al Qaeda.
The prime defendants convicted of mass murder were Jamal Zougam and Othman El Gnaoui, both Moroccan, and Jose Emilio Suarez Trashorras, a Spaniard. They were also found guilty of more than 1,800 counts of attempted murder -- one count for each of the wounded victims.
The judges sentenced the men to tens of thousands of years in prison, but the men will serve no more than 40, the maximum penalty under Spanish law.
The prime defendants acquitted of mass murder but found guilty of lesser charges included Abdelmajid Bouchar and Youssef Belhadj, both convicted of membership in a terrorist group and sentenced to 12 years in prison.
Hassan el Haski will serve 15 years for leadership in a terrorist group, and Rafa Zouhier will serve 10 years for transporting explosives.
Prosecutors had argued Zouhier was crucial to the plot because he was an intermediary between an Islamic terrorist cell in Spain and a group of Spaniards who were trafficking in explosives.
El Gnaoui, prosecutors said, ensured the explosives were transported to a home near Madrid where the bombs were assembled, and he knew they would be used in a terrorist attack.
Witnesses testified at the trial that they saw Zougam on one of the trains the morning of the bombings. Prosecutors said the only bomb that police managed to deactivate contained clues that led straight to him.
The prime defendant acquitted of all charges was Rabei Osman El Sayed Ahmed, an Egyptian. He had faced charges of mass murder, attempted murder, criminal damage and membership in a terrorist group.
Italian police provided recorded wiretaps of Ahmed in the months before the bombings in which he boasted the Madrid attacks were his "project." On the stand, Ahmed condemned the attacks, denied any link, and said the voice on the tapes was not his.
The other men on trial faced charges of membership in or collaboration with a terrorist group, or taking part in an explosives trafficking ring that was part of the plot.
In all, the judges found 21 of the 28 defendants guilty of at least some of the charges they faced. Those who walked free from court had faced charges of supplying explosives that ended up in the hands of the bombers. Watch the start of the trial
The five-month trial ended in June after hearing from hundreds of witnesses and experts. E-mail to a friend
CNN Madrid Bureau Chief Al Goodman contributed to this report