Malian and U.N. security forces launched a counterattack at the Radisson Blu Hotel in Bamako and escorted guests out. By late afternoon, no hostages were believed to remain in the building, army Col. Mamadou Coulibaly told reporters.
U.S. National Security Council spokesman Ned Price said in a written statement that the attack had ended.
Twenty-one people were killed, said Olivier Salgado, a spokesman for the United Nations peacekeeping mission in Mali. At least six people injured in the attack have been hospitalized, Mali Health Minister Marie Madeleine Togo told state broadcaster ORTM.
Al Mourabitoun said the attack was carried out in retaliation for government aggression in northern Mali, Al Akhbar reported. The group also demanded the release of prisoners in France.
Video aired by ORTM showed security personnel leading people out of the building.
"We extend our deep condolences to the families and loved ones of those who have been killed in this heinous attack. Our thoughts and prayers also are with those who have been injured," Price said.
The assault began about 7 a.m., when two or three attackers with AK-47 rifles exited at least one vehicle with diplomatic plates and entered the hotel with guns firing, Salgado said.
The attack, Salgado said, came as the hotel hosted diplomatic delegations working on a peace process in the landlocked country, a former French colony that has been battling Islamist extremists with the help of U.N. and French forces.
The Radisson chain said that as many as 170 people -- 140 guests and 30 employees -- had been there as the attack began.
Malian soldiers and U.N. troops had the hotel surrounded, a journalist for ORTM told CNN from the scene. Two security personnel were injured, Security Minister Salif Traore said on ORTM.
"We're still hearing erratic gunfire," journalist Katarina Hoije told CNN from near the scene Friday afternoon.
No group immediately claimed responsibility for the attack.
The Radisson Blu Hotel is in an upscale neighborhood outside the center of Bamako, rising high above the dusty streets and surrounding houses. With 190 rooms and suites, it is known as a hub for international guests such as diplomats and businesspeople, and it is a 15-minute drive from Bamako-Senou International Airport.
Mongi Hamdi, head of the U.N. mission in Mali, said the diplomats' meetings, which began Thursday, were a possible reason for the attack.
"I think this attack has been perpetrated by negative forces, terrorists, who do not want to see peace in Mali," Hamdi said.