Malaysia's top court on Tuesday upheld opposition leader Anwar Ibrahim's sodomy conviction in a case seen at home and abroad as politically motivated to eliminate any threats to the government.

Federal Court judge Arifin Zakat, who read the verdict on behalf of the five-judge panel, said there was "overwhelming evidence" that Anwar sodomized an aide, and therefore the court was upholding a 5-year sentence imposed by the Appeals Court last year.

This was Anwar's last avenue for appeal, and it means he will go back to prison immediately. As the last words of the verdict were read out, Anwar's wife, Wan Azizah, burst into tears. The 67-year-old politician hugged and consoled her before turning to his children and grandchildren. He smiled and hugged them too.

"I am all right," he told one of his supporters in the court room. Hundreds more were gathered outside the imposing court building in Putrajaya, the administrative capital of Malaysia. Outwardly, Anwar appeared calm and even joked with reporters in the court. In between consoling his family, he waved at reporters and said: "See you in some years."

After the verdict, the court took a break and started what's called the "mitigation proceedings," where prosecutors will ask the judges to impose a prison term longer than five years and the defense will plead for a lesser sentence.

Sodomy, even consensual, is a crime in Muslim-majority Malaysia and is punishable by up to 20 years in prison.

Judge Arifin said the defense allegations that the case was a political conspiracy "remains an allegation, unsubstantiated by any facts whatsoever." He also rejected the defense argument that the semen samples taken from the aide, Saiful Azlan Bukhari's body, were tampered with by the police.

A few hundred supporters gathered peacefully outside the court, watched by about 300 police.

The supporters are "definitely disappointed," said Edmund Teoh, 29, calling the court partial and unjust.

The verdict is the "death of justice. We will keep on fighting for a better Malaysia. We won't give up," said another supporter, Tey Khang Fai, 33.

Anwar was accused of sodomizing Saiful in 2008 when he was working in the opposition election campaign office, but was acquitted by the High Court in 2012. However, the Appeals Court overturned the acquittal in March last year and sentenced him to five years in jail. Anwar went to Federal Court to appeal that verdict.

"It is beyond reasonable doubt that (Saiful) was sodomized by the appellant. The appeal is dismissed," Judge Arifin said as he wrapped up reading the verdict, which took two hours.

Anwar, who was seen as the most potent threat to Prime Minister Najib Razak's party, has said the charges were trumped up to kill his political career.

In an immediate reaction, Najib's office said Anwar's case has gone through an exhaustive legal process, and that the case was brought by an individual, not the government.

"The process is now complete and we call on all parties to respect the legal process and judgment," said an apparently pre-written government statement, released within minutes of the verdict. "Malaysia has an independent judiciary, and there have been many rulings against senior government figures."

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. That case was also widely seen as politically motivated, as it came at a time when he was locked in a power struggle with then Prime Minister Mahathir Mohamad.

Anwar said his jailing for a second time would be toughest on his family, but that they were all very supportive.

Instead of breaking up his three-party alliance, he warned Najib that jailing him could backfire and galvanize more support for the opposition.

"They will continue with or without Anwar. No one is indispensable," Anwar said. "Authoritarian leaders always believe the best way to deal with dissidents is to jail them, but throughout history, it has always backfired," he said. "If Najib chooses to take this line -- I hope not -- then he is inviting problems for this country."

Anwar led his 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.