Kuala Lumpur: A court hearing has charged Malaysia's Anwar Ibrahim with sodomy on Thursday in a move that could harm his chances of returning to politics.

Anwar has denied the charge that he had sex with a male aide and says the charges are a government conspiracy against him.

He had hoped to contest for a parliamentary seat in an August 6 by-election and challenge the government in a confidence vote in parliament planned for September.

Anwar has been released on bail and thus will be able to contest the poll.

The opposition alliance said in a statement that it would formally propose him as leader if he won the by-election.

More than 100 supporters shouting "reform" and "long live Anwar" gathered outside the court, which was surrounded by heavy security.