"Yes, yes, I am still alive," Mr Mahathir told a news conference in the early hours of Thursday. He said his coalition would not seek revenge but would "restore the rule of law".
He also announced - to cheers among his supporters - that there would be a two-day public holiday, adding: "But there will be no holidays for the winners."
The official results showed the opposition Pakatan Harapan - the Alliance of Hope - secured 113 of the 222 seats being contested, including some which have only ever been held by the government. BN took 79 seats.
Rising living costs and long-running allegations of corruption weighed heavily on many voters and saw them peel away from Mr Najib and his once unshakeable coalition.
"I feel that with this change we probably can see something better in the future," Suva Selvan, a 48-year-old doctor, told AFP.
"Our hope for the future is a better government, fair, free and united."
How did Mahathir manage to win?
Mr Mahathir was prime minister, at the head of the BN coalition, for 22 years, from 1981 until he stepped down in 2003.
Under his leadership, Malaysia became one of the Asian tigers - the group of countries which saw their economies expand rapidly in the 1990s. But he was an authoritarian figure who used controversial security laws to lock up his political opponents.
Most infamously his deputy prime minister, Anwar Ibrahim, was sacked and accused of corruption and sodomy - and later jailed on the latter charge - when he called for economic and political reforms.
Mr Mahathir was also a mentor to Mr Najib, who became prime minister in 2008.
But Mr Najib has been dogged by corruption allegations. He has been accused of pocketing some $700m from the 1Malaysian Development Berhad, a state investment fund he set up.
He has vehemently denied all allegations and been cleared by Malaysian authorities but the fund is still being investigated by several countries. Mr Najib has been accused of stifling Malaysian investigations by removing key officials from their post.
Those allegations led to Mr Mahathir's surprise defection in 2016 from Barisan Nasional to join the Pakatan Harapan, saying he was "embarrassed" to be associated "with a party that is seen as supporting corruption".
Then in January, he said he would run for the leadership again.
But despite his historic win, uncertainty hangs over his tenure. Prior to his win, he intended to govern for two years before stepping down. He promised he would arrange a pardon for Anwar, clearing the way for him to be re-elected and take the top job.
'Mountain of challenges'
Analysis: Jonathan Head, BBC South East Asia correspondent
This morning Malaysia has woken to an entirely new situation, the first transfer of power in its history, albeit to a very familiar leader. But there are huge unknowns. How willingly will Barisan Nasional, the coalition which has, in various forms, run the country since independence and embedded itself into all areas of governance, relinquish power?
How well will a disparate coalition, united largely by their desire to oust Najib Razak, work together in government? How smoothly will the plan to gain a pardon for imprisoned opposition leader Anwar Ibrahim, and then for Mr Mahathir to hand the premiership to him within two years, actually proceed? And how will they treat Mr Najib, and his high-spending wife, both accused of greed and corruption?
After all the jubilation over an impressive act of defiance by Malaysian voters, there is a mountain of challenges to face.