Islamist militants killed 19 people in an attack on a top hotel in the capital of Mali before Malian commandos stormed the building and rescued 170 people, many of them foreigners. Two militants were killed.
President Ibrahim Boubacar Keita announced the death toll and said seven people were wounded in the attack, which has been claimed by the jihadist group Al Mourabitoun, allied to Al-Qaida and based in the desert north of the former French colony, claimed responsibility for the attack. Mali has been battling Islamist rebels for years.
"Tonight the death toll is heavy," Keita said on state television, declaring a 10-day state of emergency and three days of national mourning. The president, who cut a short visit to a regional summit in Chad, said two militants also died.
In a speech on the sidelines of a summit with Asian nations in Malaysia, U.S. President Barack Obama described the raid in Mali as "another awful reminder of the scourge of terrorism".
"Once again, this barbarity only stiffens our resolve to meet this challenge," he said. "We will stand with the people of Mali as they work to rid their country of terrorists and strengthen their democracy. With allies and partners, the United States will be relentless."
The attack is a sharp setback for former colonial power France, which has stationed 3,500 troops in northern Mali to try to restore stability after a rebellion in 2012 by ethnic Tuaregs that was later hijacked by jihadists linked to Al-Qaida.
It also puts a spotlight on veteran militant leader Mokhtar Belmokhtar, whose group Al Mourabitoun staged the attack months after he was reported killed in an air strike.
Minister of Internal Security Colonel Salif Traor said the gunmen burst through a hotel security barrier at 7 a.m. (0700 GMT), spraying the area with gunfire and shouting "Allahu Akbar", or "God is great" in Arabic.
"At first I thought it was a carjacking. Then they killed two guards in front of me and shot another man in the stomach and wounded him and I knew it was something more," said Modi Coulibaly, a Malian legal expert who saw the assault start.
The attack ended around 4 p.m. In an earlier report, a UN official said UN peacekeepers searching the hotel made a preliminary count of 27 bodies.
As troops stormed the hotel, state television showed them brandishing AK47s in the lobby. A body lay under a brown blanket at the bottom of a flight of stairs.
The U.S. State Department said one American was killed. The White House said it was working to locate all Americans in Mali, and it offered to help with an investigation and urged its citizens to limit their movements around Bamako.
A man who worked for a Belgian regional parliament was also among the dead, the assembly said. France's Defense Minister Jean-Yves Le Drian said he was not aware of any French nationals killed.
Bursts of gunfire
Bursts of gunfire were heard as the militants went through the hotel room by room and floor by floor, one senior security source and a witness told Reuters.
Some people were freed by the attackers after showing they could recite verses from the Koran, while others managed to escape or were brought out by security forces.
One of the rescued hostages, celebrated Guinean singer Sיkouba "Bambino" Diabate, said he had overheard two of the assailants speaking English as they searched an adjacent room.
"We heard shots coming from the reception area. I didn't dare go out of my room because it felt like this wasn't just simple pistols - these were shots from military weapons," Diabate told Reuters by phone.
"The attackers went into the room next to mine. I stayed still, hidden under the bed, not making a noise," he said. "I heard them say in English 'Did you load it?', 'Let's go'."
Twelve Air France flight crew members were in the hotel but all were brought out safely, the French national carrier said.
A Turkish official said five of seven Turkish Airlines staff had also managed to flee. The Chinese state news agency Xinhua said three Chinese citizens had been killed in the attack.
Only two attackers?
Northern Mali was occupied by Islamist fighters, some with links to Al-Qaida, for most of 2012. They were driven out by a French-led military operation, but violence has continued in Bamako and central Mali on the southern reaches of the Sahara.
One security source said as many as 10 gunmen had stormed the building, although the company that runs the hotel, Rezidor Group, said it understood there were only two attackers.
Al Mourabitoun has claimed responsibility for a number of attacks, including an assault on a hotel in the town of Sevare, 600 km (375 miles) northeast of Bamako, in August in which 17 people including five UN staff were killed.
One of its leaders is Belmokhtar, blamed for a large-scale assault on an Algerian gas field in 2013 and a major figure in insurgencies across North Africa.
In the wake of last week's Paris attacks, an Islamic State militant in Syria told Reuters the organization viewed France's military intervention in Mali as another reason to attack France and French interests.
"This is just the beginning. We also haven't forgotten what happened in Mali," said the non-Syrian fighter, who was contacted online by Reuters. "The bitterness from Mali, the arrogance of the French, will not be forgotten at all."