All the accused pleaded "not guilty" during the four-month trial
Moroccans Jamal Zougam and Otman el Ghanoui and Spaniard Emilio Trashorras were convicted of murder, but suspected mastermind Rabei Osman was acquitted.
Twenty-one - out of 28 on trial - were convicted and seven acquitted over the blasts on four trains that killed 191 and injured more than 1,800.
Victims' families said the accused had got off lightly.
All had pleaded not guilty to involvement in the Islamist attacks during the four-month trial.
Abuse hurled
Arriving amid heavy security to hear the result, relatives of the victims hurled abuse at the accused men, but a hush fell over the courtroom as the judge read out the verdicts.
We are going to appeal against this mistake. I don't like to see killers walking free
Pilar Manjon
Victims' spokesperson
Survivor's anger In pictures: Chapter closed Madrid digests verdict
The announcement was broadcast live on Spanish television.
The defendants, 27 men and one woman, 19 mostly Moroccan Arabs and nine Spaniards, had faced charges including murder, forgery and conspiracy to commit a terrorist attack.
Ex-miner Trashorras - who supplied the explosives - Zougam and Ghanoui were found guilty of murder, and sentenced to up to 43,000 years in jail each.
The jail terms are largely symbolic as under Spanish law the maximum term that can be served is 40 years.
Of the nine Spaniards on trial, six were acquitted.
Anger
Victims' groups were furious at the acquittals and perceived leniency of some of the sentences.
Alleged mastermind Rabei Osman Sayed Ahmed, known as "Mohamed the Egyptian", was found not guilty but is in prison in Italy after being convicted of belonging to an international terrorist group.
MADRID TRAIN BOMBINGS Bombs killed 191 people, injured 1,841 Ten backpacks filled with dynamite and nails blew up on four packed commuter trains Twenty-eight on trial - 19 Arabs, mostly Moroccans, and nine Spaniards Seven top suspects blew themselves up during police raid in April 2004 Prosecutors believe bombings were an Islamist plot All defendants pleaded innocent
The defendants Send us your reaction
Isabel Presa, who lost her youngest son in one of the blasts, said: "It has destroyed my life, it has condemned me and my husband to a life sentence, and these people get off scot-free."
The president of a victims' association, Pilar Manjon, who lost her 20-year-old son in the attacks, said: "We are going to appeal against this mistake. I don't like to see killers walking free."
But Spain's PM Jose Luis Rodriguez Zapatero said "justice was done".
Security forces were on alert across Spain as the court in Madrid began delivering its verdict at 1130 (1030 GMT) on Wednesday.
Compensation
In his summary, Judge Javier Gomez Bermudez said that all, if not almost all, the explosives used came from one source - a Spanish mine.
Compensation for victims ranging from 30,000 euros (£21,000) to 1.5m euros (£1.04m) was announced.
Analysts say the attacks changed the course of Spanish politics because in an election three days later voters ditched a conservative government that at first blamed the bombs on the Spanish separatist group Eta.
Spanish investigators say the accused were part of a local Islamist militant group inspired by al-Qaeda, but had no direct links to the terror organisation.
They had acted to avenge the presence of Spanish troops in Iraq and Afghanistan, said investigators.
Seven suspected ringleaders died in a suicide blast in a Madrid apartment three weeks after the attacks.
There were originally 29 people on trial but charges were later dropped against one defendant for lack of evidence.
La justice espagnole a condamné à presque  années de prison, trois des huit suspects des attentats du 11 mars 2004 à Madrid, attaque attribuée à Al-Qaida qui a entraîné la mort de 191 personnes et laissé  blessés.

Les hommes condamnés sont Othman El Gnaoui, un responsable de la cellule terroriste, Jamal Zougam, auteur de l'une des explosions et José Emilio Suárez Trashorras, informateur de la police espagnole et fournisseur des explosifs. La ''Audiencia Nacional de España'' a condamné les deux premiers à  années de prisons, tandis que Suárez Trashorras a été condamné à  années puisqu'on a pris en compte son .

Toutefois, la décision surprend parce que le tribunal a décidé également d'acquitter Rabei Osman, dit '''' (), accusé d'être le cerveau de l'attentat. Youssef Belhadj, pour lequel l'accusation demandait  ans de prison, en raison de son rôle de cerveau de l'attentat ainsi que de porte-parole principal du réseau terroriste Al-Qaida en Europe, a été condamné à douze ans en prison pour son rôle dans Al-Qaida. Il en fut de même pour Abdelmajid Bouchar, condamné à quinze ans de prison ; accusé d'être impliqué dans l'attentat, ses empreintes digitales furent trouvées dans une maison où furent fabriqués les explosifs.

Le marocain Hassan Al-Haski, suspecté d'être l'un des cerveaux derrière l'attentat, a été condamné à quinze ans de prison. Finalement, le dernier suspect principal et informateur de la police, Rafa Zouhier, qui aurait participé à la livraison des explosifs, a été condamné à dix ans de prison.

Le tribunal a décidé d'acquitter Antonio et Carmen Toro, personnes connues de Trashorras, ainsi que d'autres accusés : Emilio Llano, Mohamed Moussante, Javier González Díaz et Iván Granados.

Le président du Conseil espagnol, José Luis Rodríguez Zapatero, a approuvé la décision du tribunal et l'a félicité pour son travail. Toutefois, le leader de l'opposition, Mariano Rajoy, a dit que le verdict ne ferme pas le dossier, puisque .

Le 24 mars 2004, dix bombes avaient explosé dans quatre trains pleins d'employés et d'étudiants se dirigeant à la gare d'Atocha, au centre-ville de Madrid, laissant 191 morts et  blessés.

Le tribunal a vu passer 309 témoins et 71 experts pendant le procès, clos aujourd'hui.