PUTRAJAYA, Malaysia : A Malaysian court convicted opposition leader Anwar Ibrahim of sodomy and sentenced him to five years in prison on Friday, shattering his plan to take control of the country's richest state and stoking political tension in the Southeast Asian nation following a divisive national election last year.

Three judges at the Court of Appeal unanimously voted to overturn Anwar's acquittal two years ago in a rapid ruling that his supporters and international human rights groups say was politically influenced and aimed at ending his career.

The former deputy prime minister, who was previously jailed for six years on sodomy and corruption charges, will not be jailed immediately as his lawyers won a stay of the sentence pending an appeal.

But the ruling bars Anwar from running for a seat in the state assembly of Selangor this month, a move that would likely have paved the way for him to become chief minister of Malaysia's most populous state - a potent platform from which to attack the government ahead of the next national election.

If Anwar, 66, loses his federal court appeal, he would face jail and would be barred from contesting the next national election that must be held by 2018.

"It's (happening) all over again after 15 years," Anwar, who was sacked as deputy prime minister and finance minister in 1998 and convicted a year later, told reporters.

"This is a travesty of justice. This has been choreographed," he added, saying the government had underestimated "the wrath of the people".

A government spokesman said that Malaysia had an "independent judiciary". "This is a case between two individuals and is a matter for the courts, not the government," the spokesman said.