This is the second time Anwar is facing sodomy charges. He spent six years in prison after being convicted on corruption charges in 1999 and on sodomy charges involving his wife's former driver in 2000. Malaysia's highest court overturned the sodomy conviction and ordered him released from prison in 2004.
While his sodomy conviction was overturned, the corruption conviction never was -- barring him from running for office again until this year.
The ban expired in April, but it also meant Anwar could not contest the March general elections. He can re-enter Parliament through a by-election, which would make him eligible to become prime minister, a post he has openly aspired to fill.
Anwar is saying the new prosecution is aimed at preventing him from winning a parliamentary seat in an August 26 by-election and from challenging the Government in a confidence vote in Parliament planned for September.
Even as he was preparing to contest the by-election, the ruling coalition sprang a surprise on him with the new sodomy charge.
A 23-year-old male aide has accused Anwar of sodomizing him at a luxury apartment in June.
Though the charge does mean serious problems, since he has been granted bail, Anwar can now contest the poll as he had planned earlier.
The by-poll has acquired considerable significance in the context of the recent national elections in Malaysia. The ruling coalition won ultimately, but it also suffered some huge loss of face.
An opposition alliance -- with Anwar at the helm -- won 82 of 222 parliamentary seats in elections in March. It was only the second time in the country's history that the ruling party failed to gain the two-thirds majority needed to amend Malaysia's constitution.
It also lost five of the 13 states to the opposition in its worst election performance in more than 50 years.
Now the opposition hopes to lure 30 MPs from the coalition to win a September 16 vote in parliament.
The opposition alliance has issued a statement saying that it would formally propose Anwar Ibrahim as leader if he wins the by-election.
"I feel good, thank god," Anwar said after the court decision.
The court was surrounded by about 150 police, some in riot gear, and roadblocks were set up in the capital to prevent a repeat of the protests involving thousands of people staged 10 years ago when Anwar faced similar charges.
More than 100 supporters shouting "reform" and "long live Anwar" gathered outside the court.
Anwar has charged that the whole investigation is being conducted by the same police officials who, he claims, hid evidence that could have cleared him in his sodomy-related conviction in 1999.
After his arrest last month on the second sodomy charge, Anwar said, "I have not received a police report until this day. According to the law that document should be a public document. I cannot even verify that there is a complainant in the first place."
Anwar said that when the police took him into custody then, they did not talk about any evidence in the case. They only asked for a blood sample -- the same tactic they used 10 years ago to fabricate DNA evidence against him, Anwar charged.
Anwar Ibrahim, a former deputy premier, was once considered certain to succeed Mahathir Mohamad as the Prime Minister of Malysia. But the sodomy charges came in the way. Many considered they were trumped up to sabotage his chances.
Eventually his enemies succeeded at the time. He left prison in a wheelchair due to injuries he blamed on a 1998 beating by Malaysia's then police chief.
One has to wait and see whether his attempts to revive his political fortunes succeed now.