The ruling National Front coalition has won a simple majority in Malaysia's election, extending its 56-year rule.
The Election Commission said PM Najib Razak's Barisan Nasional coalition won 133 of the 222 in parliamentary seats - well short of the two-thirds majority it lost five years ago.
The opposition won 89 seats, up from 82, in Sunday's election.
Defeated opposition leader Anwar Ibrahim accused the ruling coalition of widespread fraud.
Some 80% of registered voters cast ballots, said election officials.
Voters had been faced with returning the ruling party, or choosing Anwar's untested three-party alliance, Pakatan Rakyat.
As the result was confirmed, Najib, 59, urged all Malaysians to accept his coalition's victory.
"The results show a trend of polarisation which worries the government. If it is not addressed, it can create tension or division in the country," he said.
"We have to show to the world that we are a mature democracy."
Earlier, Najib had said he was confident Malaysians would retain his coalition and even return the two-thirds parliamentary majority.
Barisan Nasional, while credited with bringing economic development and political stability, has also been tainted by allegations of corruption.
In what was considered a tight race, it had campaigned hard to shore up its base among poorer ethnic Malay neighbourhoods and in rural areas.
But Anwar refused to concede defeat, accusing the authorities of widespread abuses which he said had distorted the result of the election.
"It is an election that we consider fraudulent and the Electoral Commission has failed," he told a news conference after midnight on Monday.
Allegations of election fraud surfaced before the election.
Some of those who voted in advance told BBC News that indelible ink on their hands - supposed to last for days and show they had already voted - had easily washed off.
The opposition also accused the government of funding flights for supporters to key states, which the government denied.
Independent pollster Merdeka Center also cited unconfirmed reports of foreign nationals being given ID documents and being allowed to vote.
And the international organisation Human Rights Watch said there had been well-planned attacks against the country's independent media ahead of the polls.
Most traditional media in Malaysia are linked to the governing parties so their opponents rely almost exclusively on the internet to get their message out, correspondents say.