COLOMBO, Sri Lanka (AP) -- Sri Lanka's unpopular prime minister was elected president Wednesday, in a secret parliamentary ballot that risked reigniting turmoil among a public outraged by the South Asian nation's economic collapse.
Sri Lankans have taken to the street for months to demand their president and his prime minister step down as the country spiraled into economic chaos that left its 22 million people struggling with shortages of essentials, including medicine, fuel and food. After they stormed the presidential palace and several other government buildings last week, President Gotabaya Rajapaksa fled and then resigned.
Much of the protesters' ire is focused on Rajapaksa and his family's political dynasty, which ruled Sri Lanka for most of the past two decades, but many also blame Ranil Wickremesinghe, a six-time prime minister, for protecting him and see him as a part of the same problematic rule. Wickremesinghe was also Rajapaksa's finance minister and became acting president after Rajapaksa fled the country.
During demonstrations last week, crowds set Wickremesinghe's personal residence on fire and occupied his office.
Wednesday's vote means Wickremesinghe will finish the presidential term ending in 2024 and now has the discretion to appoint a new prime minister.
"I need not tell you the status our country is in. Now that the election is over we have to end this division," Wickremesinghe, 73, told fellow lawmakers after his victory was announced.
But it's not clear that would happen. Protesters quickly gathered outside the president's residence, chanting, "Ranil, go home."
"We are very sad, very disappointed with the 225 parliament members who we elected to speak for us, which they have not done," said Visaka Jayawware, a performance artist, in the crowd. "We will keep fighting for the people of Sri Lanka. We have to ask for a general election."
Wickremesinghe has wide experience in diplomatic and international affairs -- he noted Wednesday that he had spent 45 years of his life in Parliament -- and has led the talks on a bailout package for the bankrupt country with the International Monetary Fund.
But many voters view him with suspicion since he was appointed prime minister by Rajapaksa in May, in hopes he would restore stability.
"The struggle will continue until our demands are met. He doesn't have a mandate to rule the country," said Nemel Jayaweera, a human resources professional. "We will continue our struggle. We will oppose him."
Still, the ruling party's majority in Parliament swept Wickremesinghe to victory in Wednesday's vote, with 134 votes. Populist former government minister Dullas Alahapperuma secured 82, while a Marxist candidate netted three.
In addition to the protests, some supporters celebrated Wickremesinghe's win. He will be sworn in on Thursday.
Only a few lawmakers had publicly said they would vote for Wickremesinghe given the widespread hostility against him. But before the vote, dozens of lawmakers loyal to Rajapaksa were expected to back Wickremesinghe because he had assured them he would severely punish protesters who burned politicians' homes in the unrest.
On Monday, in his role as acting president, Wickremesinghe declared a state of emergency that gave him broad authority to act in the interest of public security and order. Authorities can carry out searches and detain people, and Wickremesinghe can also change or suspend any law.
The political turmoil in Sri Lanka has worsened the economic crisis. But Wickremesinghe said Monday that negotiations with the IMF were nearing a conclusion, while talks on help from other countries had also progressed. He also said that the government has taken steps to resolve shortages of fuel and cooking gas.
There has been no comment from the IMF on Wickremesinghe's assessment of the bailout talks.
As prime minister, Wickremesinghe delivered weekly addresses in Parliament cautioning that the path out of the crisis would be difficult, while also pledging to overhaul a government that increasingly has concentrated power under the presidency.
The vote, shown on national television, was a decorous, solemn affair. As the results were announced, the lawmakers thumped their tables in support for their own candidates.
Presidents in Sri Lanka are normally elected by the public. The responsibility falls on Parliament only if the office of president becomes vacant before a term officially ends.
That has happened only once before in Sri Lanka when then-Prime Minister Dingiri Banda Wijetunga was chosen by Parliament uncontested in 1993 after former President Ranasinghe Premadasa, father of the current opposition leader, was assassinated.