Sri Lankan MPs have elected prime minister Ranil Wickeremesinghe 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 public order after months of mass protests.
He roundly defeated party rival Dullus Alahapperuma, with 134 votes to 82 in the parliamentary vote on Wednesday.
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 Mr Wickremesinghe's resignation, who was appointed prime minister in May. Protesters burnt down his private home and also stormed his prime ministerial office in Colombo in demonstrations against his leadership.
Sri Lanka is effectively bankrupt and facing acute shortages of food, fuel and other basic supplies.
After his election, Mr Wickremesinghe told parliament the nation was "in a very difficult situation" adding that "we have big challenges ahead".
He will be aiming to restore political stability to Sri Lanka so it can resume stalled negotiations with the International Monetary Fund (IMF) for a bailout package.
He called for political unity, and for opposition parties to work with his government for the good of the country.
However his election may spark further unrest and mass protests. For the past fortnight, demonstrators had consistently been calling on Mr Wickremesinghe to step down, as they view him as part of the political elite who had mishandled Sri Lanka's finances.
Mr Wickremesinghe is a six-time prime minister who has been in Sri Lankan politics for 45 years.
He defied protesters' calls to step down last week despite major protests. He assumed the position of acting president after Mr Rajapaksa fled, and his victory on Wednesday means he will carry out the rest of the presidential term until November 2024.
His challenger Mr Alahapperuma is a dissident MP in the ruling party who gained the backing of the main opposition. He had pledged to bring a new cross-party government to Sri Lanka that would "put an end to the deceitful political culture". However he failed to muster majority support.
Sri Lanka: The basics
Sri Lanka is an island nation off southern India: It won independence from British rule in 1948. Three ethnic groups - Sinhalese, Tamil and Muslim - make up 99% of the country's 22 million population.
One family of brothers has dominated for years: Mahinda Rajapaksa became a hero among the majority Sinhalese in 2009 when his government defeated Tamil separatist rebels after years of bitter and bloody civil war. His brother Gotabaya, who was defence secretary at the time and later became president, fled the country after mass unrest.
Presidential powers: The president is the head of state, government and the military in Sri Lanka, but does share a lot of executive responsibilities with the prime minister, who heads up the ruling party in parliament.
Now an economic crisis has led to fury on the streets: Soaring inflation has meant some foods, medication and fuel are in short supply, there are rolling blackouts and ordinary people have taken to the streets in anger, with many blaming the Rajapaksa family and their government for the situation.