LIMA (Reuters) - A fiery anti-mining activist and former governor of a gold-rich region in Peru who was freed from jail on Wednesday accused the government of locking him up for two years in order to keep him from power.

Gregorio Santos welcomed the Supreme Court's decision to annul an extension of his stay in 'preventive' prison, which prosecutors probing him for corruption said was needed to keep him from fleeing Peru or obstructing their work.

Santos, who has no past convictions, never faced trial nor was found guilty of a crime. The investigation is ongoing.

"I'm only getting back what should never have been taken from me, my right to defend myself in freedom," Santos told reporters in broadcast comments after his release.

Santos, an Andean peasant leader who was elected governor of Cajamarca in 2010 and again in 2014, spearheaded protests that derailed Newmont Mining Corp's plans to expand its operations in the region, one of Peru's poorest and home to the country's biggest gold mine.

"The state has turned into a dictatorship," Santos said. "They have kept me from acting as governor and have kept me from taking part in the political life of the country."

The office of outgoing President Ollanta Humala did not immediately respond to a request for comment.

Santos has previously accused the government of Humala, who had supported Newmont's now-suspended $5 billion proposed Conga mine, of pulling strings to imprison him to pave the way for the project.

Humala has repeatedly denied the charges and has not tried to revive Conga since Newmont put it on hold in 2011 following protests that turned deadly. Santos and others oppose Conga because it would destroy Andean lakes in a farming region.

Santos ran for president from behind bars this year and garnered a better-than-expected 4 percent of votes in a crowded first-round election.

Santos did not comment on his political future on Wednesday, but a former lawmaker close to him said he would likely run for president at the next election in 2021. "Gregorio Santos is returning to his political activities heading toward 2021, to shake Peru up," Jorge Rimarachin told reporters.

After losing the first-round election, Santos broke with other leftists by refusing to endorse incoming centrist President Pedro Pablo Kuczynski in June's run-off race against right-wing populist Keiko Fujimori.

Kuczynski said this week that he thought Santos' detention was unconstitutional and that he did not see any way of reviving Conga in the near future.

(Reporting by Mitra Taj; Editing by Dan Grebler)