But the crisis that has gripped the island nation for months was far from over: Thousands of protesters demanding that the prime minster also resign rallied outside his office and some stormed the compound, as they have other official buildings in recent days. The prime minister declared a nationwide state of emergency.
President Gotabaya Rajapaksa and his wife left aboard a Sri Lankan Air Force plane bound for the Maldives, the air force said in a statement. Later, Rajapaksa appointed the prime minister as the acting president, according to the speaker of the parliament.
``What Rajapaksa did, flee the country, is a timid act,'' said Bhasura Wickremesinghe, a 24-year-old student of maritime electrical engineering. ``I'm not celebrating. There's no point celebrating. We have nothing in this country at the moment.''
While Rajapaksa agreed under pressure resign Wednesday, Prime Minister Ranil Wickremesinghe said he would leave once a new government was in place.
But that was not enough for many. Groups could be seen scaling the wall and entering the prime minister's office compound as the crowds roared in support, cheering them on, waving Sri Lankan flags and tossing water bottles to those heading inside.
``We need both ... to go home,'' said Supun Eranga, a 28-year-old civil servant. ``Ranil couldn't deliver what he promised during his two months, so he should quit. All Ranil did was try to protect the Rajapaksas.''
Police used tear gas to try to disperse the crowd but failed and more and more marched down the lane and towards the office. As helicopters flew overhead, some demonstrators held up their middle fingers.
Some protesters who appeared to be unconscious were taken to a hospital.
Protesters have already seized the president's home and office and the official residence of the prime minister following months of demonstrations that have all but dismantled the Rajapaksa family's political dynasty, which ruled Sri Lanka for most of the past two decades.
On Wednesday morning, Sri Lankans continued to stream into the presidential palace. A growing line of people waited to enter the residence, many of whom had traveled from outside the capital of Colombo on public transport.
Protesters have vowed to occupy the official buildings until the top leaders are gone. For days, people have flocked to the presidential palace almost as if it were a tourist attraction, swimming in the pool, marveling at the paintings and lounging on the beds piled high with pillows. At one point, they also burned the prime minister's private home.
At dawn, the protesters took a break from chanting as the Sri Lankan national anthem blared from speakers. A few waved the flag.
Malik D' Silva, a 25-year-old demonstrator occupying the president's office, said Rajapaksa ``ruined this country and stole our money. He said he voted for Rajapaksa in 2019 believing his military background would keep the country safe after Islamic State-inspired bomb attacks earlier that year killed more than 260 people.
Nearby, 28-year-old Sithara Sedaraliyanage and her 49-year-old mother wore black banners around their foreheads that read ``Gota Go Home,'' the rallying cry of the demonstrations.
``We expected him to be behind bars _ not escape to a tropical island! What kind of justice is that?'' Sithara said. ``This is the first time people in Sri Lanka have risen like this against a president. We want some accountability.''
As the protests escalated outside the prime minister's compound, his office imposed a state of emergency that gives broader powers to the military and police and declared an immediate curfew in the western province that includes Colombo.
The air force said in a statement that it provided an aircraft with the defense ministry's approval for the president and his wife to travel to the Maldives, an archipelago in the Indian Ocean known for exclusive tourist resorts. It said all immigration and customs laws were followed.
The whereabouts of other family members who had served in the government were uncertain.
Former Prime Minister Mahinda Rajapaksa had been living at his home in Colombo after initially taking refuge at a heavily fortified Sri Lankan naval base when he was pressured to resign in May. Basil Rajapaksa, who holds dual U.S. citizenship, resigned as finance minister in April. His own attempt to leave the country wasn't successful Tuesday. Chamal Rajapaksa, their oldest brother, was the irrigation minister and resigned in April. Namal Rajapaksa, the son of Mahinda Rajapaksa, was sports minister and youth minister and resigned in April.
``This shows what befalls a leader who uses his power to the extreme,'' said lawmaker Ranjith Madduma Bandara, a senior official of the main opposition party in Parliament, United People's Force.
Sri Lankan lawmakers agreed to elect a new president next week but have struggled to decide on the makeup of a new government to lift the bankrupt country out of economic and political collapse.
The new president will serve the remainder of Rajapaksa's term, which ends in 2024, and could potentially appoint a new prime minister, who would then have to be approved by Parliament.
Sri Lankan presidents are protected from arrest while in power, and it is likely Rajapaksa planned his escape while he still had constitutional immunity. A corruption lawsuit against him in his former role as a defense official was withdrawn when he was elected president in 2019.
Corruption and mismanagement have left the island nation laden with debt and unable to pay for imports of basic necessities. The shortages have sown despair among the country's 22 million people. Sri Lankans are skipping meals and lining up for hours to try to buy scarce fuel.
Until the latest crisis deepened, the Sri Lankan economy had been expanding and growing a comfortable middle class.
The political impasse added fuel to the economic crisis since the absence of an alternative unity government threatened to delay a hoped-for bailout from the International Monetary Fund. In the meantime, the country is relying on aid from neighboring India and from China.
Protesters accuse the president and his relatives of siphoning money from government coffers for years and Rajapaksa's administration of hastening the country's collapse by mismanaging the economy. The family has denied the corruption allegations, but Rajapaksa acknowledged some of his policies contributed to the meltdown.
Sithara said the people want new leaders who are young, educated and capable of running the economy.
As a restaurant manager in a hotel in Colombo, she once had a steady income. But with no tourists coming in, the hotel closed, she said.
``We don't know who will come next, but we have hope they will do a better job of fixing the problems,'' she said. ``Sri Lanka used to be a prosperous country.''