The case could clear the way for a comeback by Arnaldo Otegi, a former militant in Basque separatist group ETA who turned to politics in the 1990s.
Otegi was one of five people sentenced in 2010 over accusations of ETA-related crimes, and he was also given a two-year prison term on charges of encouraging terrorism.
But the plaintiffs contested the rulings, saying one of the three judges overseeing their trials had shown a lack of impartiality.
When asked by the judge whether he condemned violence by ETA during its decades-long fight for independence from Spain, Otegi had refused to reply.
The European court said the judge, Angela Murillo, had then responded that she “already knew that he was not going to give an answer to that question.”
Such a statement could have impacted the conclusions reached by the other judges, as well as their findings in the trials of the other militants, they said.
As a result, “the three-judge court panel had not been impartial” and thus violated the plaintiffs' rights to a fair trial.
Their decision was unanimous, but they did not order any payment of damages or legal costs.
“Nobody can give me back those six years in prison,” Otegi said after the verdict at a press conference at the European Parliament in Brussels, noting that his mother had died while he was behind bars.
Otegi, now 60, is a former spokesman for Batasuna, ETA's outlawed political wing, and now serves as secretary general of the Basque Sortu party.
He was released in March 2016 after being convicted of trying to resurrect the party, and that conviction had rendered him ineligible to run in Spanish regional elections that year.