At least 200 Taliban fighters crossed from Afghanistan into Pakistan and killed more than 25 soldiers and police, Pakistan's military says.
The fighters launched an early morning attack on seven military checkpoints in north-west Chitral district.
The military said its troops fought off the attackers, killing 20 of them while the rest fled back into Afghanistan.
It is the latest in a series of cross-border raids that have raised tensions between Pakistan and Afghanistan.
In its statement, the Pakistani military blamed the attack on Pakistan and Afghan Taliban-linked fighters who have sought refuge in the Kunar and Nuristan provinces of Afghanistan, from which the US largely pulled out of a year ago.
It said the "scanty presence" of Nato and Afghan forces in the border areas allow "terrorists" to use those areas as "safe havens", from which they "have mounted repeated attacks against... security forces posts and isolated villages".
The military said 25 paramilitary soldiers and police had been killed in Saturday's attack, but a local officials put the death toll at around 36.