Twelve militants were killed in the raid, which lasted several hours, the BBC reported.
Pakistan Taliban said the attack in the town of Serai Naurang in northwest Khyber Pakhtunkhwa province was in response to a U.S. drone attack last month that killed two senior commanders.
Between 25 and 30 militants were involved in the attack, police said. Eight Pakistani soldiers were wounded.
The civilians were killed when a militant wearing a suicide jacket entered a nearby house and detonated the explosives, CNN said.
Among the dead were three women and three children.
Pakistani military officials confirmed the attack.