By Tiemoko Diallo

BAMAKO (Reuters) - Around 27 people were reported dead on Friday after Malian commandos stormed a hotel seized by Islamist gunmen to rescue 170 people, many of them foreigners, trapped in the building.

The jihadist group Al Mourabitoun, which is based in the desert north of the former French colony, claimed responsibility for the attack and said it worked with al Qaeda in the Islamic Maghreb. Mali has been battling Islamist rebels for years.

A security source said the siege was over by around 4 p.m. local time (1630 GMT) and two militants were dead.

A United Nations official said U.N. peacekeepers searching the hotel had made a preliminary count of 27 bodies. The government held an emergency cabinet meeting on Friday night and was expected to give an official death toll later.

"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.

State television showed troops brandishing AK47s in the lobby of the Radisson Blu, one of the capital Bamako's smartest hotels and beloved of foreigners. A body lay under a brown blanket at the bottom of a flight of stairs.

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.

The U.S. State Department said one American had been killed. Earlier, 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 Defence Minister Jean-Yves Le Drian said he was not aware of any French nationals killed.

Minister of Internal Security Colonel Salif Traoré said the gunmen 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.

Story continues

The attacks are a slap in the face for France, which has stationed 3,500 troops in northern Mali to try to restore stability after a 2012 Tuareg rebellion which was later hijacked by al Qaeda-linked jihadists.

They also put a spotlight back on veteran militant leader Mokhtar Belmokhtar months after he was reported killed.

BURSTS OF GUNFIRE

Bursts of gunfire were heard as the assailants 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'."

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 130 people in Paris.

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.

PRESIDENT RETURNS

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, 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 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."

(Reporting by Tiemoko Diallo; Additional reporting by Adama Diarra, Joe Penney and Kissima Diagana in Bamako, Makini Brice in Dakar, John Irish in Paris, Washington and United Nations bureaus; Writing by Joe Bavier and Ed Cropley; Editing by Matthew Mpoke Bigg, Andrew Roche, Toni Reinhold)