The Pakistan Taliban have attacked an army checkpoint, killing 13 soldiers and 10 civilians, officials say.
The raid took place in the town of Serai Naurang in north-west Khyber Pakhtunkhwa province early on Saturday, and lasted several hours.
Twelve militants were killed in the attack, some of them suicide bombers, the officials said.
Pakistan Taliban say the attack was in response to the death of two commanders in a drone strike last month.
"Pakistan has been co-operating with the US in its drone strikes that killed our two senior commanders, Faisal Khan and Toofani, and the attack on military camp was the revenge of their killing," a Taliban spokesman said, quoted by Reuters news agency.
Pakistani officials have often been critical of drone strikes, but analysts say that on some occasions it has privately sanctioned such actions.
Police officer Arif Khan told the BBC between 25 to 30 militants were involved in the attack.
The Taliban said four of the attackers were suicide bombers.
Security sources said the militants were armed with automatic weapons and rocket-propelled grenades, and said they included suicide bombers.
At least eight soldiers were wounded, the sources said.
The 10 civilians, including three women and three children, were killed in a nearby house.
There are conflicting reports about whether the house was hit by a rocket or the militants broke into it.