JOHANNESBURG, South Africa (CNN) -- A South African judge has ruled Friday that the prosecution against African National Congress President Jacob Zuma was invalid, clearing the way for him to contest the presidential election early next year.
Zuma was facing trial on corruption charges that he contends were politically motivated and harmed his chances to become the ANC's nominee to be South African president next spring.
The case against Zuma had been thrown out in September 2006, but the National Prosecuting Authority recharged him.
Judge Chris Nicholson on Friday made no ruling on Zuma's guilt or innocence, but said there had been undue political influence in recharging him, and he ruled the charges were invalid.
Judge Nicholson did say, however, that he was not ruling out the possibility that the NPA might be able to reprosecute Zuma, but a decision on that would have to be made in coming weeks.
Several thousand people outside the court in Pietermaritzburg, in the coastal province of KwaZulu-Natal, erupted into cheers when they heard the announcement. Those inside the courtroom hugged Zuma and shook his hands. Watch more about the Zuma verdict in court »
Zuma is popular among poor South Africans who feel alienated by President Thabo Mbeki and long for their conditions to improve 14 years after the end of apartheid.
Zuma, a 66-year-old former guerrilla leader, has always contended the case against him was aimed at harming his chances of leading his country.
He could have spent at least 15 years in jail if found guilty of accepting bribes from a company that won a contract for a multi-billion dollar arms deal.
He also faced charges of having a corrupt relationship with his former financial advisor Schabir Shaik, who is serving a 15-year sentence for soliciting bribes for Zuma and using Zuma's political influence to benefit his businesses.
Shaik's conviction led Mbeki to fire Zuma as his deputy, but it also energized Zuma's political base.
Zuma, in a CNN interview earlier this year, said he saw nothing inappropriate about running as the ANC's presidential candidate while still facing criminal charges.
"I can feel it's not appropriate if I know I'm guilty," Zuma said. "Why should I feel it's not appropriate when I'm not guilty?"
Zuma was charged in 2005, but that case was dismissed on a technicality in 2006. He was recharged in December 2007, just days after being elected ANC president.