
Anwar, who received a police summons Wednesday ordering his appearance in court, pleaded not guilty to the charge after arriving at the Kuala Lumpur Sessions Court accompanied by his family and lawyers.
He was charged with "carnal intercourse against the order of nature," which carries a maximum 20-year jail term.
"This is malicious and treacherous slander," Anwar shouted after the charge was read out. "I am not guilty."
Sessions Court Judge SM Komathy Suppiah set bail at 20,000 ringgit (6,050 dollars) and fixed September 10 for the start of the trial. Anwar posted bail and was made to surrender his passport.
Anwar's wife, Wan Azizah Ismail, said she was "relieved" that the court had allowed Anwar to be released on bail.
"I had feared he would have been denied bail, so I'm very thankful, very relieved," she said after the hearing.
In spite of a heavy police presence and tight security around the court building, hundreds of supporters gathered outside the courtroom.
The crowd cheered when Anwar arrived and held up banners and chanted slogans supporting him.
In June, a 23-year-old former aide accused Anwar of sodomizing him.
Anwar, who turns 61 Sunday, has denied the allegations and claims he is being framed by senior police officers and politicians in a bid to thwart his rising political career.
"The true criminals are those among the leaders who seek to humiliate me and my family and seek to diminish the hopes of the people," Anwar said in his blog shortly before he was charged.
He said he would continue fighting to bring about changes for the good of the country.
"Can they stop these changes? I'm confident they cannot!" he said.
Anwar led a three-party opposition coalition to major gains in March 8 elections. The coalition denied the ruling National Front a two-thirds majority in Parliament and took control of five of Malaysia's 13 states.
Meanwhile, the civil rights group Human Rights Watch on Thursday called for the sodomy charges against Anwar to be dropped.
"The Malaysian government should immediately withdraw politically motivated charges against opposition leader Anwar Ibrahim," HRW said in a statement.
The group said police investigations into the case appeared to show the charges were meant to stop Anwar from running in a by-election due to be held on August 26.
"The Malaysian government appears to be manipulating the legal system to shore up support for its continued rule and undermine the opposition," said Brad Adams, HRW's Asia director.
"This case is really about preventing challenges to the government's rule," said Adams.
HRW said police investigation into the allegations against Anwar "has lacked transparency and impartiality."
"Pursuing this case will only undermine the credibility of the police, the prosecutor and the government," said Adams.
The latest criminal case is the second time in 10 years that Anwar has had to fight off sodomy allegations.
In 1998, former prime minister Mahathir Mohamad fired Anwar, his deputy, who was then charged with corruption and sodomy. Anwar was convicted on both charges, but the sodomy conviction was subsequently overturned, and he was released from prison in 2004.
Anwar has maintained those charges were trumped up to avert a political challenge to Mahathir.//dpa