Sri Lankan MPs have elected prime minister Ranil Wickremesinghe as the country’s new president, despite his unpopularity with the public.

Mr Wickremesinghe faces the task of leading the country out of its economic collapse and restoring order after months of mass protests.

He roundly defeated his main rival for the job, Dullus Alahapperuma, with 134 votes to 82 in a parliamentary vote.

Sri Lanka’s ex-president Gotabaya Rajapaksa fled the country last week.

He bolted to the Maldives and then Singapore after thousands of protesters stormed his presidential residences and other government buildings, calling for his resignation.

They had also called for the resignation of Mr Wickremesinghe, a close ally of the Rajapaksa political family who was appointed prime minister in May.

Protesters last week burnt down his private home and also stormed his prime ministerial office in Colombo in demonstrations against his leadership.

On Wednesday, many expressed despair and disappointment over his win.

“I am absolutely disgusted at the result… I cannot believe that 134 people – MPs that are supposed to represent the people- have completely disregarded the wants of the people,” one activist Jeana De Zoysa told the BBC.

Mr Wickremesinghe is viewed by many as a shrewd political operator who’s managed to cling on in parliament despite his party losing all but one of their seats in the 2020 election.

A former six-time prime minister, he failed in his previous two runs for the presidency. His victory on Wednesday means he will serve out the rest of the presidential term until November 2024.

But on Wednesday, after sweeping the vote with the backing of the Rajapaksa’s ruling party, he called for unity and bipartisanship moving forward.

He told parliament the nation was “in a very difficult situation” and there were “big challenges ahead”. Sri Lanka has been wracked with protests for months because the country is effectively bankrupt and facing acute shortages of food, fuel and other basic supplies.

Mr Wickremesinghe is aiming to restore political stability so the country can resume negotiations with the International Monetary fund for a bailout package.

He was involved in these talks last month, and the ruling Sri Lanka Podujana Peramnua (SLPP) party said most of their members had backed him because of his economic credentials.

“We feel that Ranil Wickremesinghe is the only person with the experience, the know-how and the capacity to provide solutions to the economic crisis,” General Secretary Sagara Kariyawasam told the Reuters news agency.

However, it remains unclear whether he will be accepted by protesters – many of whom say he’s part of the political elite behind the country’s economic mismanagement.

On Wednesday, ahead of the results, barricades were set up around the parliament and soldiers lined the perimeter anticipating crowds.

Policemen stand guard at a barricade outside the Parliament building

But protesters remained fairly subdued. After the result, some gathered at the Galle Face Green protest site chanted “Ranil Go Home”.

There are fears among some that Mr Wickremesinghe will now crack down on the movement, which has brought hundreds of thousands of ordinary people onto the streets demanding change.

When he assumed the job of acting president last week, he ordered the military to do whatever was necessary to restore public order, following protesters storming and occupying government buildings.

He also extended a national state of emergency order this week to stamp out any flare-ups.

However, his immediate challenges include sourcing fuel supplies and managing the public discontent – which will mean working on removing the bitterness, anger and disappointment within society.

His main challenger in Wednesday’s vote was Mr Alahapperuma, a dissident MP in the ruling party who gained the backing of the main opposition. He had pledged to bring a cross-party government to Sri Lanka that would “put an end to the deceitful political culture” but failed to muster enough support.