Page last updated at 23:44 GMT, Wednesday, 30 June 2010 00:44
The activists were serving long prison terms for the alleged kidnapping of police officers during a protest in the town of
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
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
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
A report by
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.
One of those released is the leader of the protests, Ignacio del Valle.
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.
Donations can be sent to the
"The master class has always declared the wars; the subject class has always fought the battles. The master class has had all to gain and nothing to lose, while the subject class has had nothing to gain and everything to lose--especially their lives." Eugene Victor Debs