The former French colony has been battling Islamist rebels for several years, and the jihadist group Al Mourabitoun, allied to al Qaeda and based in the deserts of northern Mali, claimed responsibility for the attack in a tweet.
By late afternoon, ministerial adviser Amadou Sangho told the French television station BFMTV that no more hostages were being held.
But a U.N. official said U.N. peacekeepers on the scene had seen 27 bodies in a preliminary count, and that a search of hotel was continuing. It was not clear whether any of the gunmen, who were said to have dug in on the seventh floor of the hotel as special forces advanced on them, were still active.
State television showed footage of troops in camouflage fatigues wielding AK47s in the lobby of the Radisson Blu, one of Bamako's smartest hotels and beloved of foreigners. In the background, a body lay under a brown blanket at the bottom of a flight of stairs.
The peacekeepers saw 12 dead bodies in the basement of the hotel and another 15 on the second floor, the U.N. official told Reuters on condition of anonymity. He added that the U.N. troops were still helping Malian authorities search the hotel.
A man working for a Belgian regional parliament was among the dead, the assembly said.
Minister of Internal Security Colonel Salif Traoré said the gunmen had burst through a security barrier at 7 a.m. (0700 GMT), spraying the area with gunfire and shouting "Allahu Akbar", or "God is great" in Arabic.
BURSTS OF GUNFIRE
Occasional bursts of gunfire were heard as the assailants went through the seven-storey building, 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 were brought out by security forces or managed to escape under their own steam.
One of the rescued hostages, celebrated Guinean singer Sékouba 'Bambino' Diabate, said he had overheard two of the assailants speaking in English as they searched the room next to his.
"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'."
The raid on the hotel, which lies just west of the city centre near government ministries and diplomatic offices, came a week after Islamic State militants killed 129 people in Paris, raising fears that French nationals were being specifically targeted.
Twelve Air France flight crew were in the building but all were extracted 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 of 10 Chinese tourists caught inside had been rescued.
Malian President Ibrahim Boubacar Keita cut short a trip to a regional summit in Chad, his office said.
Northern Mali was occupied by Islamist fighters, some with links to al Qaeda, for most of 2012. They were driven out by a French-led military operation, but sporadic violence has continued in Mali's central belt on the southern reaches of the Sahara, and in Bamako.
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 that there were only two attackers.
Al Mourabitoun has claimed responsibility for a number of attacks in Mali, 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 U.N. staff were killed.
One of its leaders is Mokhtar 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 organisation 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."