Malaysia's scandal-ridden former leader Najib Razak was hit with a travel ban Saturday as speculation mounted he was about to flee the country following his shock election loss, in a possible bid to avoid prosecution over a massive financial scandal.

An angry crowd had gathered at a Kuala Lumpur airport, shouting at vehicles and seeking to stop them entering, after Najib tweeted that he was going to take a ‘short break’ with his family.

Reports had circulated online he and his unpopular wife Rosmah Mansor were set to board a flight to Indonesia.

The defeat of Najib's Barisan Nasional (BN) coalition in last week's poll by an alliance led by his once mentor Mahathir Mohamad was a political earthquake, which toppled an increasingly authoritarian regime that had ruled the country for six decades.

Speculation had been mounting that Najib, who has been embroiled in a massive scandal related to state fund 1MDB, might try to flee the country.

Mahathir, who came out of retirement to take on his ex-protege Najib, has pledged to investigate the controversy in which Najib is accused of involvement in stealing huge sums of money. Najib and 1MDB deny any wrongdoing.

At 92, Mahathir is the world's oldest elected leader. He previously served as prime minister for over two decades, and was accused of ruling with an iron fist.

As images of a manifest for a flight to Jakarta circulated online, Najib said in social media posts he was planning to take a short break to rest after the election and would return next week.

But as speculation mounted Najib and his wife were about to board a flight, the immigration department announced they were banned from leaving Malaysia.

‘The immigration department has just now blacklisted Najib and Rosmah from leaving the country,’ Mustafar Ali, director-general of the immigration department, told AFP.

Najib said in a tweet: ‘I have just been informed by the immigration department of Malaysia that my family and I are not allowed to go abroad. I respect the decision and I will remain in the country with my family.’

Rosmah has long been a lightning rod for public anger in Malaysia due to her reported love of luxury shopping trips and vast collection of designer handbags.

- 'Suffered so long' -

Earlier, dozens of people descended on the airport in a bid to stop them leaving. Riot police were stationed by the gate of the airport where it was believed Najib would enter.

As a white van with heavily tinted windows attempted to pass by, the crowd surrounded the vehicle and demanded it be opened so they could see who was inside.

They tried to rock the vehicle and one man shouted ‘I hate Rosmah’.

It was only allowed to pass after those inside rolled down a window to prove Najib was not in the van.

Businessman Raja Singham, 49, who had tried to block the van from entering, said: ‘We have the right to know who is inside the car, as a citizen I will fight for that. We have suffered for so many years. I don't want them to get out of the country.’

Mahathir was expected to announced his cabinet line-up later Saturday.

In the latest dizzying development after last week's shock poll results, Mahathir announced Friday that the king has agreed to pardon jailed leading politician Anwar Ibrahim, his former nemesis turned ally.

This would pave the way for Anwar's return to politics and to potentially become premier later. Mahathir has said he plans to eventually hand the premiership to Anwar.

Anwar was heir-apparent to Mahathir until they had a dramatic falling out. Mahathir sacked him in 1998, and he was subsequently jailed. He was released and then imprisoned again under Najib's rule in 2015.

Mahathir and Anwar reconciled in recent years in a bid to oust Najib, an extraordinary twist even by the head-spinning standards of Malaysian politics.