“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 courthouse 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 underestimate 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.

The guilty verdict means that Anwar will be unable to run for a seat in Selangor, one of four states ruled by his opposition alliance, later this month. Anwar was expected to take over as chief minister of Selangor if he had won the election.

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.

“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.’’

Anwar previously was imprisoned for six years after being ousted as deputy prime minister in 1998 on earlier charges of sodomising his former family driver and abusing his power. Anwar was freed in 2004 after Malaysia’s top court quashed that sodomy conviction.