Malaysia's prime minister narrowly won a vote to remove the parliament speaker during a rowdy session of the legislature Monday, a key test of support for the embattled leader.

The Southeast Asian nation has been gripped by turmoil since a reformist government collapsed in February and Muhyiddin Yassin became premier, at the head of a coalition backed by a scandal-plagued party.

He took power without an election, and there had been speculation he did not have sufficient support from MPs to hang on to power.

But in a closely watched vote as parliament resumed following a break due to the coronavirus pandemic, his motion to remove the speaker won the support of 111 MPs against 109 for the opposition.

It was the first time that a speaker had been removed in such a fashion in Malaysia, and sparked fury from the opposition.

"What happened today is a travesty of justice, death of parliamentary democracy and stifling of (the) people's mandate," tweeted opposition lawmaker Charles Santiago.

"Challenging days ahead for the country."

After the removal of Mohamad Ariff Mohamad Yusof -- who had been appointed by the previous administration -- the premier tabled a motion for him to be replaced by Azhar Azizan Harun.

Malaysia's Prime Minister Muhyiddin Yassin, seen here in March, is at the head of a coalition backed by a scandal-plagued party
Malaysia's Prime Minister Muhyiddin Yassin, seen here in March, is at the head of a coalition backed by a scandal-plagued party AFP / Mohd RASFAN

The opposition demanded a vote and sought to propose an alternative candidate, but former election commission chief Azhar was hurriedly sworn in without one.

A shouting match erupted between rival MPs, with opposition lawmakers chanting "vote, vote, vote" and one branding Azhar a "back-door speaker" -- and subsequently being ordered to leave the chamber.

James Chin, a Malaysia expert from the University of Tasmania, said the victory was important for Muhyiddin as the speaker decides whether a vote of confidence should go ahead.

Mahathir Mohamad, who was premier until resigning in February amid political turmoil, had been pushing for such a vote.

"Going forward, Muhyiddin is in a stronger position politically," Chin told AFP.

"Now that the speaker is obviously more partial towards his group, he will find it a lot easier to control parliament."

Malaysia's political crisis began in February when 95-year-old Mahathir quit and his multi-racial coalition, which had swept to power at landmark 2018 elections, collapsed amid bitter infighting.

It was replaced by a government headed by Muhyiddin and dominated by the United Malays National Organisation, a scandal-mired party which had been ejected at the polls.