Keita resigned in a brief address broadcast on state television after troops seized him along with Prime Minister Boubou Cisse and other top officials.
"Today, certain parts of the military have decided that intervention was necessary. Do I really have a choice? Because I do not wish blood to be shed," Keita said from a military base in Kati outside the capital Bamako where he had been detained earlier in the day.
The soldiers behind the coup - calling themselves the National Committee for the Salvation of the People - appeared on state television in military fatigues, pledging to stabilise the country.
"We are not holding on to power but we are holding on to the stability of the country," said Ismail Wague, Mali Air Force's deputy chief of staff.
"With you, standing as one, we can restore this country to its former greatness," said Wague, announcing borders were closed and a curfew was going into effect from 9pm to 5am.
"This will allow us to organise within an agreed reasonable timeframe, general elections to equip Mali with strong institutions, which are able to better manage our everyday lives and restore confidence between the government and the governed."
The Economic Community of West African States (ECOWAS) has condemned the coup attempt in Mali and has moved to suspend the country from its decision-making body, according to Al Jazeera's Ahmed Idris, who is reporting from Abuja in Nigeria.
In an announcement, the regional alliance also said that neighbouring countries of the West African state are closing its borders and will impose sanctions as the crisis continues.
- Countries: Africa