Footage from inside the hotel shows some of the hostages being freed by security forces
Suspected Islamist gunmen who stormed a hotel in Mali's capital, Bamako, have "no more hostages", officials say.
The Radisson Blu Hotel was stormed by special forces after gunmen entered it and seized 170 people, many of them foreign guests.
Al-Qaeda in the Islamic Maghreb and its offshoot al-Murabitoun said they carried out the attack, according to an agency used by jihadists in the region.
An unnamed UN official has said at least 27 people have been killed.
The official, who spoke on condition of anonymity, said 12 bodies were found in the basement and 15 bodies were found on the second floor.
It is not clear if this includes two of the attackers who are reported to have died.
Special forces are said to be still battling some gunmen in the hotel.
One of the hostages killed was Geoffrey Dieudonne, a member of parliament in Belgium's Wallonia region.
UN mission spokesman Olivier Salgado says he cannot yet confirm if the operation is over, the AP news agency reports.
Security ministry spokesman Amadou Sangho told Reuters news agency that some of the gunmen were still "dug in in the upper floors".
"They are alone with the Malian special forces who are trying to dislodge them."
Pictures show some of the hostages leaving the hotel were wounded; earlier, the interior minister said two soldiers had been injured.
Rescued hostage: "I heard gunshots very early in the morning"
Hostages of many different nationalities had been seized by the militants
Some of the hostages rescued from the building had been wounded
The US-owned hotel is popular with foreign businesses and airline crews.
Eyewitnesses said the gunmen had entered the hotel shooting and shouting "God is great!" in Arabic. It is not clear how many attackers there were - there are reports of up to 13.
The claim by an obscure Saharan jihadist group allied to al-Qaeda that they were behind the attack is a reminder that the country still faces an insurgency.
In 2013 French forces effected a stunningly swift reversal of al-Qaeda's takeover of most of Mali. But Mali is a large, poor country with porous borders and large areas of ungoverned space where jihadist groups have been able to hide and plan attacks.
It has not been helped by the ease with which weapons can come across from Libya, nor by the proximity of a murderous insurgency in Nigeria where Boko Haram reportedly killed more people last year than Islamic State did in Syria and Iraq.
It is clear that Mali will continue to need international military support. But to defeat terrorism in the long term it will also need secure borders, good governance and more economic opportunities for young Malians.
Before special forces stormed the building, a security source told Reuters that some hostages who were able to recite verses of the Koran were being freed.
Mali's presidency has tweeted (in French) thanking the security forces and friendly countries for their support in responding to the attacks.
Off-duty US servicemen helped in the hostage rescue operation. French special forces were dispatched to the scene.
There is as yet no established link with the attacks in Paris one week ago that killed 130 people.
In August, suspected Islamist gunmen killed 13 people, including five UN workers, during a hostage siege at a hotel in the central Malian town of Sevare.
France, the former colonial power in Mali, intervened in the country in January 2013, when al-Qaeda-linked militants threatened to march on Bamako after taking control of the north of the country.
Mali's President Ibrahim Boubacar Keita has cut short a trip to a regional summit in Chad.
His French counterpart Francois Hollande said: "We should yet again stand firm and show our solidarity with a friendly country, Mali."
The UN force in Mali took over responsibility for security in the country from French and African troops in July 2013, after the main towns in the north had been recaptured from the Islamist militants.
Militancy in Mali: