Prime Minister Najib Razak's National Front coalition captured 25 parliamentary seats while opposition leader Anwar Ibrahim's three-party alliance seized 13 in the earliest results released by Malaysia's Election Commission. At least 112 of the 222 parliamentary seats at stake are needed to win federal power.
Many of the seats won so far are in the National Front's traditional rural strongholds in Borneo, where Anwar's alliance was hoping to make major inroads to bolster its chances of winning.
The National Front has triumphed in 12 consecutive general elections since independence from Britain in 1957, but it was facing its most unified challenge ever from an opposition that hoped to capitalize on widespread allegations of arrogance, abuse of public funds and racial discrimination against the National Front.
Initial counting showed the opposition retained strong support in urban constituencies, especially in Kuala Lumpur, Malaysia's biggest city, and was almost certain to retain control of northern Penang state, one of Malaysia's wealthiest territories.
More than 10 million Malaysians cast ballots for a record turnout of 80 percent of about 13 million registered voters, the Election Commission said in preliminary estimates.
Some people lined up for more than an hour at schools and other voting centers, showing off fingers marked with ink to prevent multiple voting after they had finished.
The National Front held 135 seats in the 222-member Parliament that was dissolved last month. It is anxious to secure a stronger five-year mandate and regain the two-thirds legislative majority that it held for years but lost in 2008.
"The government has made some mistakes but the prime minister has made changes and I believe they (the National Front) will do their best to take care of the people's welfare," said Mohamed Rafiq Idris, a car business owner who waited in a long line at a central Selangor state voting center with his wife and son.
Andrew Charles, a Malaysian businessman working in Australia, flew home to vote for the opposition because he believes it can end corruption and mistrust between the Malay Muslim majority and ethnic Chinese, Indian and smaller minorities.
"I am really fed up. There are more abuses in the system and there is no equality among the races. After 56 years, it is time to give others a chance to change this country," he said after voting in a suburb outside Kuala Lumpur.
Najib says only the National Front can maintain stability in Malaysia, which has long been among Southeast Asia's most peaceful and wealthier countries.
"Your support is paramount if we are to keep to our path of development, if we are to continue our journey toward complete transformation," Najib said in a statement to voters. "This election is about fulfilling promises, bringing hope and upholding trustworthiness."
Many political observers believe the race will be tight, with the National Front potentially edging out Anwar's alliance partly because of its entrenched support in predominantly rural districts.
The opposition is likely to retain control of at least two of Malaysia's 13 state legislatures and should perform well in urban constituencies where middle-class voters have clamored for change.
If the opposition wins, it would mark a remarkable comeback for Anwar, a former deputy prime minister who was fired in 1998 and subsequently jailed on corruption and sodomy charges that he says were fabricated by his political enemies. He was released from jail in 2004.
"We stand today on the brink of history," Anwar said in a statement. "Sunday's election will mark the decisive step in an amazing, peaceful, democratic revolution that will take Malaysia into a new era."
The opposition is worried about electoral fraud, saying the National Front was using foreign migrants from Bangladesh, the Philippines and Indonesia to vote unlawfully. Government and electoral authorities deny the allegations.
The National Front's aura of invincibility has been under threat since three of Malaysia's main opposition parties combined forces five years ago. In recent years the National Front has been increasingly accused of complacency and heavy-handed rule.
Najib, who took office in 2009, embarked on a major campaign to restore his coalition's luster. In recent months, authorities have provided cash handouts to low-income families and used government-linked newspapers and TV stations to criticize the opposition's ability to rule.