Malaysia's high court has ruled that prosecutors have established a credible sodomy case against Anwar Ibrahim, forcing the opposition leader's lawyers to start presenting defence witnesses next month.

The ruling dashed Anwar's hopes of an immediate end to a trial that could lead to his imprisonment for up to 20 years. Anwar insists the government concocted the charge that he sodomised a 25-year-old male former aide. The prime minister, Najib Razak, and other officials have denied plotting against Anwar.

Further trial hearings will distract Anwar as he prepares his three-party opposition alliance for general elections that are widely expected within a year. Najib's ruling coalition is working to regain at least a two-thirds parliamentary majority and recapture several states that Anwar's alliance gained in 2008 polls.

The high court judge Mohamad Zabidin Diah said on Monday he believed that Saiful Bukhari Azlan, one of Anwar's former aides, seemed truthful and reliable while testifying that Anwar made him have sex in a Kuala Lumpur apartment in 2008.

"I find a prima facie case has been made out against the accused," Mohamad Zabidin told a packed courtroom. "Therefore I call upon the accused to enter his defence."

Hearings were scheduled to run from 6-30 June. Sodomy, even consensual, is a crime in Muslim-majority Malaysia.

Anwar's lawyer, Sankara Nair, said the opposition leader would be the defence's first witness. His team might also question the prime minister and dozens of other people, including foreign medical experts.

"We know this is a case of a major conspiracy involving the prime minister, his wife" and the former national police chief, Anwar told reporters.

Saiful wrote on Twitter that he was thankful for the court's ruling. He said he would remain patient and was praying that the rest of the trial would proceed smoothly.

The judge said prosecutors had presented sufficient evidence to corroborate Saiful's testimony, including DNA samples from semen found on his body that allegedly matched Anwar's. Defence lawyers insist authorities obtained some of the samples illegally and handled them wrongly.

Anwar said he considered his position "very precarious" because Mohamad Zabidin dismissed many of the defence's key arguments. The judge said he found it understandable that Saiful did not try to escape Anwar's alleged sexual advances or file a police complaint sooner because he had long idolised Anwar and was concerned about his future.

It is the second time Anwar has been involved in a sex trial. He lost his post as deputy prime minister in 1998 after being charged with sodomising his family's former driver and abusing his power to cover up his actions, both of which he denied. He was freed in 2004 after six years in prison when a court overturned the sodomy conviction.

The 63-year-old, who is married with six children, has recently denied allegations that he had sex with a prostitute after two former politicians and a businessman leaked a sex video they claimed featured Anwar.