Thousands of civilians were forced to flee the Khyber Agency, the security forces said on Thursday, as the army stepped up a two-week-old offensive against Taliban militants in the area.
Twenty-one suspected militants and eight soldiers were killed on Wednesday, the security forces said in a statement.
National disaster officials said the fighting has forced more than 18,000 people to abandon their homes.
Residents of the area said they are caught between the two opposing forces, as the security forces orders them to leave and the militants urge them to stay.
“Security forces were asking us to leave their area as there would be heavy bombing against the militants,” said one villager, Muddasir Shah.
But the militants had set up bunkers and were patrolling villages to prevent residents from leaving, he added.
“The militants were saying we shouldn’t flee the villages.”
The security forces have killed dozens of militants in airstrikes and fighting since the operation began in Khyber.
“The militants wanted people not to leave their houses so that the military don’t use fighter jets and artillery against them,” said Khair Zaman, 47, who had spent nine hours wandering on unfrequented back roads moving his family to safety.
On Sunday, the military said it had killed 18 militants in airstrikes.
The Khyber offensive began two weeks ago in the area around the Tirah Valley, a key smuggling route into neighbouring Afghanistan.
At the same time, the military is pressing on with a campaign against the Taliban it launched in nearby North Waziristan in June.