By Simon Fraser
BBC News
The move came as the island was placed under curfew after violent clashes between Rajapaksa supporters and anti-government protesters in Colombo.
Five people have died, including a ruling party MP, and more than 190 injured in violence in the capital.
There have been protests over soaring prices and power cuts since last month.
The island nation is facing its worst economic crisis since gaining independence from Britain in 1948.
Mr Rajapaksa, 76, sent his resignation letter to his younger brother President Gotabaya Rajapaksa, saying he hoped it would help resolve the crisis, but the move is highly unlikely to satisfy government opponents while the latter remains in power.
A partial victory for protesters
In a nation facing a crisis of economic uncertainty, Mahinda Rajapaksa’s resignation was no surprise. There had been days of speculation he’d go – after reports his brother had told him he needed to quit.
In the last few days Mahinda Rajapaksa held on, with the view that as the more popular of the brothers, he shouldn’t be the one to go – but in the end he was.
Before he said goodbye, he addressed his loyal supporters at a rally in the morning – some of them were later seen attacking anti-government protesters.
As news of the PM’s departure reached Colombo’s sea front promenade, Galle Face Green, demonstrators danced with glee. For weeks they’ve been demanding the Rajapaksa family, which has ruled on and off for decades, resign.
But this is seen as just a partial victory – their real target is the president. He shows no signs of quitting, which means the protests will continue.
Earlier in on Monday, police and army riot squads were deployed following violence outside the prime minister and president’s offices in Colombo.
After pulling down tents of protesters outside the PM’s Temple Trees residence, they then stormed the nearby “Gota go home” camp on the promenade.
“We were hit, the media were hit, women and children were hit,” one witness told AFP news agency.
Just outside the capital in the town of Nittambuwa, police said thousands of protesters surrounded the car of an MP from the governing party. He opened fire, killing one man. The MP himself was later found dead, as was his bodyguard, AFP reports citing police.
Another MP in the southern town of Weeraketiya also opened fire on protesters at his house, killing two and wounding five others, according to AFP.
Mobs set fire to several properties of ruling party politicians and local government officials were attacked, reports said.
Since demonstrations erupted in early April, protesters have been camped noisily but peacefully outside President Rajapaksa’s office at Galle Face Green, demanding he quit.
People are furious because the cost of living has become unaffordable.
Sri Lanka’s foreign currency reserves have virtually run dry, and it can no longer afford essential items including food, medicines and fuel.
The government has requested emergency financial help. It blames the Covid pandemic, which all but killed off Sri Lanka’s tourist trade – one of its biggest foreign currency earners.
But many experts say economic mismanagement is to blame.
The prime minister’s letter said his resignation was intended to clear the way for an “all-party government to guide the country out of the current economic crisis”, AFP reports.
Opposition parties have so far refused to do so and have also called on the president to quit.
Humiliating exit after years in power
Ayeshea Perera, Asia editor, BBC News
Mahinda Rajapaksa’s resignation marks an ignominious change in fortune for a man who for years was simply Sri Lanka’s most powerful man.
His decade as president saw him oversee the crushing of the Tamil Tiger rebels in 2009, but he was dogged by allegations of serious human rights abuses, as well as claims – which he strenuously denies – that he was corrupt while in power.
He was denied a third term as president in 2015. But less than five years later he was back – although this time as prime minister, serving as the right-hand man of younger brother Gotabaya.
The allegations of corruption have added fuel to the current protests – many people believe Mahinda Rajapaksa paved the way for his family to plunder the country’s wealth for their own financial gain.
Billboards and chants demanding the family return the country’s “stolen money” are a common sight at the protests across Sri Lanka.
-
Sri Lanka: ‘I am young but I see no future here’
-
Why Sri Lankans want their rulers thrown out
-
The divisions behind Sri Lanka’s united protests