Three judges at the Court of Appeal unanimously voted to overturn Anwar's acquittal two years ago in a rapid ruling 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.
Anwar, who was sacked as deputy prime minister and finance minister in 1998, said outside court: "It's (happening) all over again after 15 years. This is a travesty of justice."
A government spokesman said Malaysia had an independent judiciary.