The wife of jailed Malaysian opposition leader Anwar Ibrahim has won his seat in a by-election, officials said on Friday, one of two votes held this week that were seen as a test of Prime Minister Najib Razak's leadership.

Anwar's family has held the seat in Penang state for decades. His wife, Wan Azizah Wan Ismail, retained it in Thursday's vote over the candidate from the ruling Barisan Nasional, Suhaimi Sabudin, although with a slightly reduced majority.

Anwar held the seat of Permatang Pauh until he was jailed in February for sodomy, a charge he says was a politically motivated attempt to end his career. His family's request for a royal pardon was rejected last month, necessitating the by-election.

Najib and the ruling coalition have been under pressure leading up to two by-elections this week.

Much of that pressure has been over his management of the economy and a number of scandals, including over the debt-laden state fund 1MDB, use of the colonial-era Sedition Act and the murder of a Mongolian model nine years ago.

Malaysia's former long-time leader Mahathir Mohamad has since publicly called for Najib to step down.

Support for Anwar and public outrage over a new goods and services tax has helped the three-party opposition alliance, Pakatan Rakyat, shore up support against the government.