KUALA LUMPUR, Malaysia — A Malaysian court on Friday sentenced opposition leader Anwar Ibrahim to five years in jail on sodomy charges, overturning an earlier acquittal and throwing his political career into jeopardy.
An angry Anwar vowed to appeal to the country's highest court. He accused Prime Minister Najib Razak's government of orchestrating his conviction and warned that it "faces the wrath of the people."
The court said Anwar could remain free on bail during the appeal.
Anwar, 66, is the most potent threat to Najib, whose party has ruled Malaysia since independence in 1957. Najib's popular support has weakened over the last two elections.
If Anwar loses the appeal, he will have to give up his Parliament seat and go to prison. He would also be disqualified from contesting any elections for five years after his release.
The conviction means that Anwar will be unable to run for a seat in Selangor, one of four states ruled by the opposition, later this month. He was expected to take over as chief minister of Selangor, boosting the opposition, if he had won the election.
Sodomy, even consensual, is a crime in Muslim-majority Malaysia and is punishable by up to 20 years in prison.
The United States and international human rights groups called the legal moves against Anwar politically motivated.
"In this high-profile case, it's critical for Malaysia to apply the rule of law fairly, transparently and apolitically in order to promote confidence in Malaysia's democracy and judiciary," U.S. State Department spokeswoman Jen Psaki said in Washington.
Anwar was accused of sodomizing a male aide in 2008 but acquitted by the High Court in 2012. The government appealed that decision.
Appeals Court Judge Balia Yusof Wahi said Friday that the lower court's decision to acquit Anwar was wrong.
"We unanimously allow this appeal and set aside the decision of the High Court," he said. Anwar "is convicted and sentenced to five years' jail," he added.
The verdict sparked an uproar in the court and triggered an outpouring of support for Anwar on Twitter. Anwar's wife and children were in tears and dozens of supporters outside the court house shouted "Free Anwar."
"It is a clear signal to the people of Malaysia that they are not interested in (the country's) economic malaise ... but they are interested in killing political opponents," Anwar said, referring to Najib's government.
"They want to end Anwar's political career but they underestimated the wrath of the people," he said.
The government said in a statement that the judiciary was independent and the case was a matter for the courts, not the government, to decide.
"Therefore, to respect the legal process and the rights of those involved, it would be inappropriate for the government to comment further," it said.
Friday's verdict is the latest development in a long-running legal campaign against Anwar, who has maintained that the sodomy charges were trumped up.
Anwar previously was imprisoned for six years after being ousted as deputy prime minister in 1998 on earlier charges of sodomizing his former family driver and abusing his power. He was freed in 2004 after Malaysia's top court quashed that sodomy conviction.
Since then, he has led a three-party alliance to unprecedented gains in 2008 elections and made further inroads in 2013 polls. Najib's National Front coalition won with a slimmer majority and lost the popular vote to the opposition.
"This trial was all about knocking Anwar Ibrahim out of politics, pure and simple, and the government was prepared to jump through whatever hoops were necessary to make that happen," said Phil Robertson of the New York-based group Human Rights Watch. "It's a dark day for the Malaysia judiciary, which has shown today how hard it is to get a free and fair trial when political issues are in play."
Associated Press writer Matthew Pennington in Washington contributed to this report.