By Trinna Leong and Al-Zaquan Amer Hamzah
KUALA LUMPUR (Reuters) - The biggest political threat to Malaysia's government is behind bars after a court upheld a sodomy conviction for opposition leader Anwar Ibrahim, but more thorny problems confront Prime Minister Najib Razak.
Anwar, jailed for five years on Tuesday on a charge he called politically motivated, has for years represented the greatest challenge to Najib's coalition, which has ruled the multi-ethnic Southeast Asian country since independence in 1957.
The bespectacled former finance minister and deputy prime minister cemented a three-party opposition alliance which took on the coalition at the last polls in 2013, costing the ruling bloc the popular vote in its worst-ever electoral performance.
Deserted at the polls by ethnic minority Chinese and urban voters, Najib's party will now face the fallout of sharper polarization over Anwar's jailing, amid widespread perceptions that his prosecution was motivated by political vengeance.
"There's something rotten about the whole thing," said former cabinet minister Zaid Ibrahim. "It's not good for the country and democracy, never mind Najib."
"Even to prosecute Anwar for these kind of affairs is just unreasonable, it carries such a heavy sentence," he added.
The government denied interference in Anwar's case.
While Anwar's jailing could bolster Najib's standing among hard-liners at home, foreign investors are likely to be alarmed at a time when Malaysia is facing sliding oil and gas revenues.
The United States was "deeply disappointed" with Anwar's conviction, which "raised a number of serious concerns about rule of law and the fairness of the judicial system", said U.S. National Security Council spokeswoman Bernadette Meehan.
But more damaging for Najib than foreign reproach over Anwar is likely to be criticism at home of his leadership, especially from within his own party.
"He has put the opposition challenge away for a couple more years, but his immediate problems are from internal critics and it will probably get worse," said Ibrahim Suffian, the director of the Kuala Lumpur-based research firm Merdeka Center.
Unfortunately for Najib, his biggest critic is former Prime Minister Mahathir Mohamad, who led Malaysia for 22 years until 2003 and remains influential.
Najib is a self-described moderate who came to power with reformist plans. The more conservative Mahathir has made no bones about what he thinks of Najib's premiership.
Last year, in a savagely critical blog post, Mahathir said he was withdrawing support from Najib. This month, Mahathir said there was "something rotten in the state of Malaysia" and openly questioned Najib's handling of the country.
"If you don't perform and people say you're no good, please resign," Mahathir told news portals.
"As for Najib, I don't know if he is performing."
Najib has quietly set aside his liberal agenda, dashing hopes for social reform and the scrapping of old security laws used to stifle dissent.
But it is not only Najib's leadership that his critics have questioned. His personal life has come under scrutiny amid reports of his family's lavish spending.
There is also suspicion of mismanagement at state investment firm 1MDB. Najib is chair of its board of advisers. Concern over 1MDB's $11.6 billion of debt has pressured the ringgit and the country's sovereign credit rating.
Now that Anwar is out of the picture, Najib's detractors in the ruling party could set their sights on him, analysts and government insiders say.
"Anwar's exit is quite a big risk for Najib," said Wan Saiful Wan Jan from the Institute for Democracy and Economic Affairs.
"UMNO leaders will be more vocal about Najib's flaws," he said, referring to the ethnic Malay party at the heart of the ruling coalition.
A source close to the government said Anwar's jailing was "not in the prime minister's domestic or international interests".
Malaysia next election must be held by 2018 and sympathy for Anwar could stoke support for the opposition.
"This is a silver lining for the party in a way ... it's Pakatan's opportunity to show they can function without Anwar," said Wan Saiful, referring to the diverse Pakatan Rakyat alliance.
Anwar's politician daughter, Nurul Izzah, said the opposition must stay united.
"We have no chance if we do not present a cohesive union," Narul told Reuters.
"Everyone has to step up. This is not Anwar Ibrahim's personal quest. He has been attacked for 17 years because we got together to challenge the government."
(Additional reporting and writing by Praveen Menon; Editing by Clarence Ferenandez, Robert Birsel)