Spain's Supreme Court has overturned the convictions of four people found guilty of involvement in the 2004 Madrid train bombings.
The four were among 21 people convicted last year over the attacks, which killed 191 people.
The court also upheld the acquittal of an Egyptian suspected of masterminding the attacks, because he had already been convicted of the offence in Italy.
However it convicted and jailed one of those originally found not guilty.
The Spanish man, who was sentenced to four years in prison, had earlier been cleared of helping to supply the explosives used in the Madrid attacks.
The Egyptian man, Rabei Osman Sayed Ahmed, had been cleared of involvement in the bombings in October.
Rabei Osman Sayed Ahmed had already been convicted in Italy
As he had already been sentenced to eight years in prison in Italy for belonging to a terrorist organisation, the court ruled he could not be convicted again for the same crime.
Prosecutors had argued that Sayed was appealing against the Italian judgement and technically had not been convicted.
Sayed's lawyers in that case are challenging key evidence - a recording in which he apparently boasts of masterminding the bombings.
They say the voice heard is not his, and that it has been mistranslated.
Last October, a Spanish court cleared three men of masterminding the attack and acquitted seven others, while convicting 21 people for involvement in the attack.
Many victim support groups were angered by the acquittals and said the sentences handed down were much lower than those requested by the state attorney.
The decision to overturn some of those convictions due to insufficient evidence will not please these groups, says the BBC's Danny Wood in Madrid.
Jesus Ramirez, a survivor of the attacks, said he accepted the court ruling even if he did not agree with it.
"Even though we may oppose it in our hearts, they have more information and have weighed the evidence and made a decision," he told the Associated Press.
The train bombings killed 191 people and injured 1,800
Meanwhile, Luca D'Auria, Sayed's Italian lawyer, expressed satisfaction at the verdict.
"Both myself and (Sayed's) Spanish lawyer have always imagined it would end this way - I am extremely satisfied," he said.
The Madrid bombing - in which 10 rucksack bombs tore through four packed commuter trains on 11 March 2004 - was Europe's most deadly terror attack since the 1988 Lockerbie bombing.
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 said the bombers 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.
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.