The soldiers from a regiment based in Andalusia had been charged over alleged torture at the Spanish military base in Diwaniya, Iraq on an "unspecified date" in either January or February 2004.
In the incident, three Spanish soldiers brutally kicked two Iraqi men who were lying on the floor of a holding cell while two soldiers looked on. A sixth soldier, who was not charged, filmed the incident.
But in a surprise decision, a Spanish military court has dropped the charges against the men, Spain's El País reported on Thursday.
In their ruling, the presiding judges argued that while the crime had undoubtedly taken place and was "unquestionably serious" in nature, the case did not have legs because it was impossible to ascertain the identity of the victims.
Using a doctrine established by the US administration under George W. Bush as it embarked on its war on terror in the wake of September 11th 2001 attacks in the US, the court argued that the Geneva Conventions on armed conflict applied only to civilians and prisoners but not to suspected terrorists.
The judges then suggested that the victims of the attack being investigated could have been suspected terrorists who had been transferred to the Spanish military base in January 2004 on suspicion of having been involved in a mortar attack on a US base in Iraq.
The ruling saw the court ordering a judge to keep investigating in a bid to try and identity the victims of the attack. But the tribunal also recognized this would be almost impossible to ascertain as a log book providing details of detainees at the Diwaniya base had been lost.
Military judges did not rule out the possible that the five men could be tried under Spanish criminal law under articles dealing with torture by public officials and the causing of serious injury to protected persons during armed conflict.