Anwar Ibrahim, Malaysia's opposition leader, has been acquitted of sodomy charges after a long-winded trial that lasted for two years.

Anwar, who was accused of having sex with a former female aide, insisted all along that he was innocent. "Thank God justice has prevailed, I have been vindicated. To be honest, I am a little surprised," the BBC quoted him as saying soon after the verdict.

Judge Zabidin Mohamad Diah refused to admit DNA evidence submitted by the prosecution. "The court is always reluctant to convict on sexual offences without corroborative evidence. Therefore, the accused is acquitted and discharged," the judge said.

Government sources, reacting to the verdict, said it showed the independent nature of the country's judiciary.

There were jubilant scenes outside the court where the verdict was announced. Anwar's supporters welcomed the judgment with loud cheers.

The new turn of events marks the re-emergence of Anwar who has been widely accepted as Malaysia's reformist leader. The court verdict is seen as a huge boost for him, especially in view of the elections to be held in 2013.

Charges of corruption and sodomy surfaced against Anwar, the former deputy prime minister of Malaysia, shortly after the elections in 2008 in which his party made significant gains.