Mali's President Ibrahim Boubacar Keita announced his resignation on live television in the early hours of Wednesday morning following a military coup.
"I've decided to leave my post," he said, clad in traditional clothing and a medical mask to protect against Covid-19.
The president and Prime Minister Boubou Cisse were arrested by the military after a mutiny on Tuesday, following months of street protests in the volatile West African state, which is also battling an Islamic insurgency.
"The president and his prime minister have been arrested," army officer Sidi Gakou told earlier Tuesday. "They are being taken to Kati military camp."
The United Nations, European Union, African Union Commission, and the African Union Commission and the Economic Community of West African States (ECOWAS), condemned the military's actions.
The UN secretary general called for the "immediate release" of the president, while the EU said it "condemns the coup attempt under way in Mali and rejects any anti-constitutional change."
"This can in no way be a response to the deep socio-political crisis that has hit Mali for several months," the EU statement added.
Later, ECOWAS said that it decided to close its member states' borders with Mali, suspend the country from its decision-making bodies "with immediate affect," and temporarily interrupt financial flows between its other 14 members and Bamako.
Gunfire heard in Bamako
Mali has been struggling to maintain stability since tens of thousands of opposition supporters accused Keita of gross intimidation and vote-buying during a parliamentary election in April, which gave his administration a firm majority.
Soldiers started to mutiny early Tuesday in the garrison town of Kati, 15 kilometres north-west of Bamako. Gunfire was heard in the capital. A photographer told there had been several thousand protesters on the streets, with people firing into the air in celebration.
Before its leaders were detained, the government had released a statement calling for calm, admitting that soldiers might have legitimate frustrations and saying they were prepared to engage in a dialogue.
The US, Australian, and Swedish embassies in Mali warned of possible unrest in the volatile West African nation, urging their citizens to stay at home.
France, a former colonial power in Mali, condemned the mutiny.
"France has learned with concern of the mutiny that has started today in Kati, Mali. It condemns this serious event in the strongest terms," the Foreign Ministry said in a statement.
The coup come after several weeks of political tensions and repeated anti-government protests during which talks between the government and the opposition, which is led by popular cleric Mahmoud Dicko, a former ally of Keita, failed.
A coup in Mali in 2012 was carried out by soldiers from the same barracks.
Political instability in Mali is seen as a dangerous development for the entire Sahel region, which already faces ongoing threats from numerous terrorist and separatist groups.