On the campaign trail, Mr. Mahathir apologized for enabling Mr. Najib to become prime minister in 2009.
“The biggest mistake that I have made in my life is choosing Najib,” he told voters last week.
Mr. Mahathir, who will turn 93 in July, has tried to unite a fractured opposition and attract ethnic Malay voters long loyal to the governing party.
Mr. Najib, however, has many political advantages, including a strong party organization, greater access to campaign funds and gerrymandered districts that favor his National Front coalition.
Malaysia also has weak campaign finance laws that allow for a flood of election spending without identifying the source of donations or disclosing how the money is distributed.
On the eve of the election, Mr. Najib promised that if his coalition won, he would exempt everyone 26 and younger from paying taxes and declare two public holidays next week, which would come just before the start of the holy month of Ramadan.
Mr. Najib has been embroiled for years in a scandal over billions of dollars that disappeared from a government investment fund that he once headed, One Malaysia Development Berhad.
The United States Justice Department concluded that $3.5 billion from the Malaysian fund was laundered through financial institutions in the United States and spent on items like expensive real estate, jewelry, paintings and the production of movies, including “The Wolf of Wall Street.”
The Justice Department concluded that $731 million in government funds was deposited into bank accounts belonging to Mr. Najib. United States officials cited the “astonishing greed” of individuals involved in the scam.
The Justice Department is conducting a criminal investigation and filed civil suits to recover $1.7 billion in assets acquired with laundered money, including a $27.3 million diamond necklace received by Mr. Najib’s wife, Rosmah Mansor, and a $3.2 million painting by Pablo Picasso that was given to the actor Leonardo DiCaprio.
Several other countries also are investigating transactions associated with the missing money.
Malaysian officials, however, have said there is no evidence that money from the investment fund was misappropriated.
Mr. Najib has held on to power by halting investigations, dismissing critics, prosecuting opponents and maintaining the support of his conservative Muslim base.
President Trump, who once golfed with Mr. Najib and declared him “my favorite prime minister,” did him a favor in September by inviting him to the White House.
The trip allowed Mr. Najib to show voters at home that he could go to the United States without being arrested. While in Washington, he and his entourage stayed at the Trump International Hotel.
Newsletter Sign Up
Thank you for subscribing.
An error has occurred. Please try again later.
You are already subscribed to this email.
Mr. Najib mentioned the Washington visit in a statement Monday as he asserted that his government is respected abroad.
“The truth is that Malaysia’s standing in the world is very high,” he said.
More than anyone, Mr. Mahathir created the strong government that Mr. Najib has used to stay in power. But in his attempt to unseat Mr. Najib in this campaign, he joined with opposition leaders he once sent to jail.
Many of Mr. Mahathir’s new allies saw aligning with him as the best way to bring back the former opposition leader Anwar Ibrahim, who narrowly lost to Mr. Najib in 2013 and is due to be released from prison next month after his second conviction on sodomy charges.
Both of Mr. Anwar’s convictions — the first under Mr. Mahathir and the second under Mr. Najib — were widely seen as politically motivated.
In his campaign, Mr. Mahathir, who has long criticized Mr. Najib’s use of government payouts as a political tool, sought to highlight the investment fund scandal.
“Instead of fighting for its people, country and religion, Najib believes that trust can be bought with money,” he said in his final campaign speech. “We are also not known as having democracy, instead as a kleptocracy.”