Najib Razak took over as prime minister on Friday
Malaysian Prime Minister Najib Razak has faced his first major test since taking office last week, as voters cast ballots in three by-elections.
In the parliamentary seat being fought, the opposition Pan-Malaysian Islamist party increased its majority over the prime minister's governing coalition.
But Mr Razak's coalition won the state seat in Sarawak. Partial results show the opposition leading in Kedah.
The results will not change the balance of power in government.
However, the elections are being seen as an indicator of the level of support for Mr Najib's leadership.
He has already pledged far-reaching reforms to revive the government's flagging popularity.
About 100,000 voters were eligible to vote in the three polls - for a national parliament seat in Bukit Gantang in Perak state, and two state parliament seats in Kedah and Sarawak.
The election in Perak was particularly tense, as Mr Najib had a leading role in a campaign to oust the opposition-led state government there earlier this year.
The Pan-Malaysian Islamist party said its victory there - by a margin of 2,789 votes - was an indication that people were "sick with the political turmoil" in the state.
Tensions were high before the vote, with minor scuffles reported between rival sides.
According to partial results, the opposition is also leading the contest for the state seat in Kedah, which neighbours Perak.
In Sarawak on the island of Borneo, the ruling National Front coalition retained the state seat with a majority of 1,854 votes, up about 1,000 votes from the last state election.
Mr Najib has taken over as Malaysia's leader at a time when the country and its coalition government, which has ruled since 1957, are facing big challenges.
The National Front is facing a revitalised opposition - the People's Alliance, a three-party coalition led by Anwar Ibrahim.
The Malaysian economy is also deteriorating, and last year the main ruling party, Umno, suffered a poor election showing, leading to the decision of the previous prime minister, Abdullah Badawi, to resign.
Shortly after taking office, Mr Najib announced an ambitious agenda to reform the party, focusing on the economy and repairing ties between the ethnic Malay population and the nation's Chinese and Indian minorities.