Security forces in Burkina Faso retook a hotel in the capital from al-Qaeda fighters who seized it in an assault that killed two dozen people from at least 18 countries and marked a major escalation of Islamist militancy in west Africa.

Until yesterday's attack, the Burkina Faso had largely been spared the violence that has plagued its neighbours.

The assault follows a similar raid in November on a luxury hotel in Mali's capital Bamako which killed 20 people, including citizens of Russia, China and the United States.

The Ouagadougou assault, claimed by al-Qaeda in the Islamic Maghreb (AQIM), marked an expansion of operations for Islamist militants who are stepping up their activities, echoing the growth of the so-called Islamic State in the Middle East.

President Roch Marc Christian Kabore said 23 people of 18 different nationalities were killed in the 146-room Splendid Hotel and a nearby Cappuccino restaurant popular with Westerners and French soldiers based in Burkina Faso. The authorities gave no further details of the victims.

One Cappuccino survivor said diners at first mistook the gunfire and explosions for firecrackers before two gunmen, dressed all in black and brandishing AK-47 assault rifles, burst in, firing indiscriminately.

"We heard shots, grenades, detonations. It was echoing and extremely loud. It went on for a long time," the survivor said.

"The situation we're experiencing since yesterday in Burkina Faso is unprecedented," Mr Kabore said when he visited the scene of the attack. "These are vile, cowardly acts and the victims are innocent people."

French ambassador Gilles Thibault put the death toll at 27 and said on Twitter that around 150 hostages had been freed in an operation that received support from French and US forces.

Burkinabe authorities said that around 33 people had been injured and that four assailants, including an "Arab" and two "black Africans", were killed.

Another survivor, a French man who was at an outdoor bar near Cappuccino when the attacks started, said he saw three assailants singling out white victims before running into the Splendid hotel.

Meanwhile, two Australians have been kidnapped in Burkina Faso, officials said, as a Malian Islamist group said the couple were in the hands of al-Qaeda-linked jihadists.

The Burkina government said the pair were kidnapped in Baraboule, near the west African country's borders with Niger and Mali.

A Burkinabe intelligence source said the Australians were a couple in their 80s from the western city of Perth who had lived since 1972 in Djibo, near Baraboule.

The attackers torched cars and fired in the air to drive people back before entering the Spendid Hotel and taking hostages last night.

French and US military personnel backed up Burkina Faso security forces when they launched their operation to reclaim the Splendid Hotel in the early hours of this morning, though their progress through the building was slowed by explosives planted by the militants.

France normally has up to 200 special forces troops in the country as part of a regional anti-militant operation.

A witness said major clashes ended after a period of sustained gunfire and explosions that appeared to focus on the Cappuccino restaurant early today.

Sporadic gunfire continued through the morning however. The final assailant was killed later in another nearby hotel, the Hotel Yibi, officials said.