A total of 126 people were freed, including 33 wounded, from the four-star Splendid hotel, popular with Westerners and UN personnel, after security forces retook the 147-room facility and the Cappuccino restaurant nearby in the early hours of Saturday, Interior Minister Simon Compaore told AFP news agency.
The jihadists' assault in Ouagodougou had been completely crushed by midday Saturday, a security source said. Four jihadists, including two women, were killed in the counter-assault.
Al-Qaeda in the Islamic Maghreb (AQIM) claimed responsibility for the attack saying it was "revenge against France and the disbelieving West", according to a statement carried by US-based monitoring group SITE.
The attackers were members of the Al-Murabitoun group based in Mali and run by Mokhtar Belmokhtar, SITE said.
The security source said at least 23 people from 18 countries were killed in the jihadists' assaults, adding that the toll could yet rise.
Aside from the four jihadists killed, a fifth attacker could be seen rushing into a nearby bar, according to witnesses who managed to escape.
French first responders tend to wounded people in the surroundings of the Splendid hotel. Photo: Nabila Al Hadad/AFP
Compaore told AFP earlier that firefighters had seen 10 bodies on the terrace of the restaurant.
A total of "126 people, including at least 33 wounded, have been freed. Three jihadists -- an Arab and two black Africans -- have been killed," Compaore said.
President Roch Marc Christian Kabore, who took office just last month, visited the hotel Saturday but made no immediate comment.
Communication Minister Remis Dandjinou told AFP the counter-assault was carried out by Burkinabe troops with the support of French special forces. He also said that among those who escaped unharmed was Labour Minister Clement Sawadogo.
- 'There was blood everywhere' -
Early Saturday, a fire raged at the main entrance of the hotel in Ouagodougou and screams could be heard from inside, while on the street outside about 10 vehicles were set alight.
"It was horrible, people were sleeping and there was blood everywhere. They were firing at people at close range," Yannick Sawadogo, one of those who escaped, told AFP.
"We heard them speaking and they were walking around people and firing at people who were not dead. And when they came out they started a fire."
The attack comes less than two months after a jihadist siege at the luxury Radisson Blu hotel in the Malian capital Bamako left 20 people dead, including 14 foreigners -- an attack claimed by the same Al-Qaeda affiliate behind the Ouagadougou assault.
The head of the city's main hospital said prior to the start of the counter-assault that 20 people had been killed and that there were "more white people than black" among the dead.
A French source meanwhile put the death toll at 27 dead.
An AFP reporter at one point saw three men clad in turbans firing at the scene on Avenue Kwame Nkrumah, one of Ouagadougou's main thoroughfares.
A witness also reported seeing four assailants who were of Arab or white appearance and "wearing turbans".
SITE published a clip from a phone conversation with one of the fighters participating in the attack.
"I counted 18 but there are at least 30 dead," the jihadist claims.
- 'Odious, cowardly' -
The French embassy said on its website earlier that a "terrorist attack" was underway and urged people to avoid the area. French President Francois Hollande in a statement condemned the "odious and cowardly attack".
With Ouagadougou airport closed because of the attack, and an Air France flight from Paris to Ouagadougou was diverted to neighbouring Niger.
A US defence official, speaking on condition of anonymity, said Washington could provide drone-based surveillance.
Story continues below…
The Burkinabe army, meanwhile, said a heavily-armed group of about 20 people had also carried out an attack on Friday near the border with Mali, killing two people -- a police officer and a civilian -- and leaving two others wounded.
France's ambassador to the country said a curfew had been put in place in Ouagadougou from 11pm to 6am. Gilles Thibault tweeted that the embassy had set up a crisis unit for its citizens.
More than 3,500 French nationals live in the former colony, according to foreign ministry data.
In April the Romanian security chief of a mine in northern Tambao was kidnapped in a move also claimed by Belmokhtar's Al-Murabitoun group.
Burkina Faso is part of the G5 Sahel grouping that counts the fight against terrorism as part of its remit.
It has also offered support to France's Barkhane counter-terror mission, spanning five countries in Africa's restive Sahel region, and French special forces are stationed in Ouagadougou's suburbs.
Last month, Burkina Faso swore in Kabore as president, completing the troubled West African state's transition after the overthrow of its longtime ruler Blaise Compaore in 2014 and a failed coup attempt in September.