Demonstrators had demanded the release of the "Atenco 12" |
The activists were serving long prison terms for the alleged kidnapping of police officers during a protest in the town of San Salvador Atenco in 2006.
But the judges found there had been no real evidence against them.
Last week 11 Nobel peace prize winners asked President Felipe Calderon to release the activists.
Human rights groups have hailed the ruling as a victory in the fight against miscarriages of justice in Mexico.
'Criminalising protest'The 12 members of the Peoples Front for the Defence of Land were serving sentences of between 31 and 112 years for their part in disturbances in San Salvador Atenco four years ago.
They had been found guilty of kidnapping six policemen during violent protests which broke out in May 2006 after the arrest of local market vendors accused of selling flowers in a neighbouring town without a permit.
But the supreme court found that - even if they had detained officials during the protest - it did not amount to kidnapping.
"The evidence was illegal and insufficient, they were not given due process, and the crime of kidnapping was never proved," the court ruled.
One judge, Juan Silva Meza, said the case appeared to have been "a disguised form of criminalising social protest" in Mexico.
The police were accused of using excessive force in Atenco |
Thousands of federal and state police stormed the town and battled demonstrators, who fought back with machetes and petrol bombs.
Two protesters were killed and at least 26 women were allegedly sexually assaulted by police.
San Salvador Atenco already had a reputation for staging protests after a successful campaign in 2002 against the construction of a new airport for Mexico City on local land.
One of those released is the leader of the protests, Ignacio del Valle.
His daughter America sought asylum in the Venezuelan embassy in Mexico City last week - the first Mexican to do so in many years.
Last week 11 former Nobel peace prize laureates, including Jody Williams of the US, Wangari Maathai of Kenya and Bishop Desmond Tutu sent a letter to demand the release of the 12 prisoners and justice for the people of Atenco.