Burkina Faso's president declared three days of national mourning from Thursday after suspected jihadists killed 47 people, including 30 civilians, in an attack in the north of the country.
The attack was the latest bloodshed in an area plagued by Islamist violence.
The assault Wednesday near the town of Gorgadji also left 14 soldiers and three militia volunteers dead, the communications ministry said.
The soldiers and militia had been "guarding civilians setting off for Arbinda," another town in northern Burkina.
In an ensuing gunbattle, security forces killed 58 "terrorists" and put the rest to flight, according to the government. Nineteen people were also wounded, it said.
"Rescue and relief operations are continuing," it said.
The area is in the notorious "three-border" zone where Burkina Faso meets Mali and Niger, a focus of the jihadist violence that plagues the wider Sahel region of west Africa.
It was the third major attack on Burkinabe soldiers in the past two weeks, including one on August 4 near the Niger border which killed 30 people, including 11 civilians.
President Roch Marc Christian Kabore declared three days of national mourning from Thursday for the victims of the latest attack, according to an official decree.
Flags would be flown at half-mast from public buildings and festivities banned during the period, it said.
Burkina Faso, a poor country in the arid sub-Saharan Sahel region, has since 2015 been battling increasingly frequent and deadly attacks by jihadist groups affiliated with the Islamic State group and Al-Qaeda.
On June 4-5, gunmen killed at least 132 people, including children, in the northeast village of Solhan, Burkina's deadliest attack in the history of the insurgency.
Raids and ambushes have been concentrated in the north and east close to the borders with Mali and Niger, both of which have also faced deadly violence by jihadists.
These attacks along with inter-communal violence have left more than 1,400 people dead and forced 1.3 million to flee their homes, according to official estimates.
Along with central Mali, the vast, arid "three-border" region straddling Niger, Mali and Burkina Faso has become the worst-hit area in the jihadists' Sahel campaign.
Militants linked to Al-Qaeda emerged in northern Mali in 2012, prompting French military intervention. After being scattered, the jihadists regrouped and spread to neighbouring countries.