An election monitoring group meanwhile complained that ballot papers had been interfered with.
With results declared early this morning in all 193 constituencies, the ruling National Front coalition had won 149 parliamentary seats, well above the two-thirds majority which it needs to pass amendments to the constitution. But the four-party Alternative Front, led from prison by Mr Mahathir's former friend and deputy, Anwar Ibrahim, returned 43 MPs, and in regional elections, Mr Mahathir's government lost control of a second state to an Islamic fundamentalist party.
Mr Anwar is in prison on charges of corruption and sodomy, but last night his wife, Wan Azizah Wan Ismail, won his old seat as the candidate of the newly formed Justice Party. "This is a victory of the people," she said early this morning. "It shows that people dared to choose change."
But Mr Mahathir, speaking at a press conference, said: "As far as we are concerned, they gave us more than a two-thirds majority. And that's clear proof that they want us to carry on with our job. Elections are not meant for quarrelling with people. We would be very glad to work with the opposition parties outside of politics."
The biggest upset came in the eastern state of Terengganu, a centre of the gas and oil industries, where the Malaysian Pan-Islamic Party (Pas) gained control of the state legislature, as well as retaining the northern state of Kelantan. But among a number of blows suffered by the opposition, the country's most experienced and respected opposition leader, Lim Kit Siang of the Chinese Democratic Action Party, lost his parliamentary seat, after one of the bitterest and most acrimonious election campaigns in Malaysian history.
Yesterday, an independent election monitoring group said that it had received complaints of irregularities, including reports that portions of some ballot papers had been impregnated with wax, making it impossible for voters to mark the boxes of opposition parties. "Our phones have not stopped ringing," said Kamar Ainiah Kamaruzaman of Pementau.
Little more than a year ago, tens of thousands of people took to the streets of Kuala Lumpur calling for the resignation of Mr Mahathir, after the sensational sacking and arrest of Mr Anwar, Mr Mahathir's deputy, finance minister and designated successor. Mr Anwar's appearance in court, bruised and beaten by the chief of police, outraged many Malaysians, among them natural supporters of the government.
But yesterday the long record of economic development and the continued stability promised by the authoritarian Mr Mahathir won out over the greater freedom and reform demanded by the opposition. "I wasn't interested in politics, but the Anwar business made me think a lot more about it," said Johan bin Mohamed Saleh, a 40-year old factory manager, at a polling station in the city of Shah Alam. "But you can't deny where this country's going - the new airports, dams, highways."