President Roch Marc Kabore declared two days of national mourning in the west African country in response to the attack.
The incident followed an attack on a mining convoy in November, which killed nearly 40 people.
Militants attacked the military detachment in Soum province on Tuesday morning. After several hours, troops repelled them and seized a large number of weapons and motorbikes, the army said in a statement.
As they fled, they "killed 35 civilians of whom 31 were women", the government said in separate statement. It said 80 militants and seven members of the security forces were killed during fighting which had taken place earlier.
Burkina was once a pocket of relative calm in the Sahel region, but its homegrown insurgency has been amplified by a spillover from its chaotic northern neighbor Mali.
Attacks over the past year have killed hundreds and forced nearly a million people from their homes.