Sri Lankan shares ended higher on Friday to post their first weekly gain in three as the country's President, Gotabaya Rajapaksa, who has fled to Singapore, resigned.

At the close of trade, the CSE All-Share index was up 2.04% at 7,467.82, led by gains in consumer and financial stocks. For the week, the index gained 5.47%.

Conglomerate Carson Cumberbatch Plc and LOLC Finance were the top gainers on the index, advancing nearly 19% and 7%, respectively.

The speaker of Sri Lanka's parliament formally accepted President Gotabaya Rajapaksa's resignation on Friday after he fled to Singapore to escape a popular uprising over his handling of a devastating economic crisis.

The island nation is currently facing its worst economic crisis in seven decades, unable to pay for essential imports such as fuel and medicine due to a severe shortage of foreign exchange.

Sri Lanka's newly appointed acting President Ranil Wickremesinghe said on Friday that he would follow constitutional process and establish law and order in the country.

The political turmoil gripping the island nation of 22 million comes amid negotiations with the International Monetary Fund (IMF) over a rescue plan.

The IMF is still in contact with officials at technical levels within the Sri Lankan government and hopes to be able to resume discussions with higher-level officials, an IMF spokesman said on Thursday.

On the CSE All-Share index, trading volume rose to 66.5 million shares from 44.5 million shares in the previous session.

The equity market turnover was 1.11 billion rupees ($3.07 million), up from 625.8 million rupees in the earlier session, according to exchange data.

Foreign investors were net buyers in the equity market, purchasing 21.7 million rupees worth of shares, while domestic investors were net sellers, offloading nearly 1.10 billion rupees worth of shares, the data showed.

(Reporting by Rama Venkat in Bengaluru; Editing by Shinjini Ganguli)