But the two-thirds majority in parliament his coalition has held for most of its five-decade-long rule was in doubt.
The poll, called before it was due in May 2009, was widely seen as a referendum on Badawi's rule.
Full results were expected on Sunday.
Early results showed the Chinese-backed Democratic Action Party (DAP) won Penang, an industrial state that is home to many multinational firms.
Koh Tsu Koon, Penang's chief minister, said: "This is the biggest defeat ever since our (party's) founding 40 years ago. I feel sad and surprised.
I urge all Barisan Nasional members to stay calm and not to take any action that could jeopardise peace and security in the state."
The Pan-Malaysian Islamic Party (PAS) claimed surprise wins in the northern states of Kedah and Perak while beating out the ruling coalition in PAS' stronghold in northeastern Kelantan state.
The opposition was also reported to be gaining in Selangor state surrounding Kuala Lumpur, the state news agency Bernama said.
Police fired tear gas to disperse a crowd of 300 opposition supporters at a poll-related incident in northeastern Terengganu state earlier on Saturday.
Twenty-two people were arrested after throwing stones at busses, allegedly carrying people they feared would cast bogus votes.
PAS supporters stopped several buses and cars which they suspected were transporting BN supporters pretending to be voters from the district.
Musa Hassan, a local police chief, told a news conference: "The PAS supporters threw stones at police vehicles, forcing the police to release tear gas to control the situation."
Large crowds had flocked to opposition rallies during the campaign, especially ethnic Chinese and Indian voters unhappy with the BN government, dominated by politicians from the Muslim majority of ethnic Malays.
Ethnic Chinese and Indians make up about one-third of the population and many complain of discrimination by the government in favour of Malays, in terms of education, jobs, financial assistance and religious policy.
In the last election in 2004, the BN won nearly 64 per cent of the vote and more than 90 per cent of the seats in the lower house of parliament.
Opposition parties are hoping to deny the coalition a two-thirds majority that enables the government to make changes to the constitution without parliamentary debate.Badawi's warning
Badawi told voters the night before the elections that they could cause instability and chaos if they abandoned BN, implying that racial tensions could flare up.
|"You have to vote for our future, you have to vote for our children... What will happen if there is chaos and there is instability?"|
Abdullah Badawi, prime minister of Malaysia
In 1969, after Barisan suffered a major electoral setback, race riots broke out in which hundreds of people were killed and a two-year state of emergency followed.
Badawi said: "You have to vote for our future. You have to vote for our children... What will happen if there is chaos and there is instability?"
Experts say Badawi's continued leadership could be in jeopardy if his majority falls back below 80 per cent, or around 178 seats in the new 222-seat parliament.
The election, which will also decide the make-up of state assemblies, has been tainted by allegations of vote-rigging.
After casting his vote on Saturday, Nik Aziz Nik Mat, the leader of the main opposition Islamist party, said his supporters had found a member of the main ruling party in possession of 28 identity cards for use in electoral fraud.
Nik Mat's Parti Islam se-Malaysia (PAS) controls northeast Kelantan state, the only opposition-held state, and faces a major campaign by BN to win it back after 18 years of PAS rule.
Tricia Yeoh from the Centre for Public Policy Studies told Al Jazeera that this election is going to be drastically different to the last.
"There has been, in the past four years, an increasing disquiet in almost all sectors of society," she said.
"This is due to a number of reasons...the failure of the administration to curb corruption [AND] the growing income disparity between different societies in Malaysia."
Yeoh said the electoral system is in need of reform because of conditions that are unfavourble towards the opposition.
"There is media bias. You have gerrymandering, non-transparent administration procedures," she said.