Pakistani security officials broke up more than a dozen militant sanctuaries in the Khyber tribal region this week and killed 23 fighters, they said, while tribal sources said pro-Taliban groups killed 20 pro-government militants.
The Lashkar-e-Islam and Tehrik-e-Taliban Pakistan (TTP) militant groups attacked villages in the Tirah region and killed residents when they tried to stop them entering the area, the security officials said, requesting anonymity.
Tirah is a maze of valleys on a route from Afghanistan to the Pakistani city of Peshawar.
The Pakistani military and pro-government militias have since 2009 clawed back territory from the Taliban, who once controlled land a few hours' drive from the capital of Islamabad.
Pakistani government officials say the NATO withdrawal of troops from Afghanistan in 2014 might strengthen the Taliban in Pakistan. The Afghan and Pakistani Taliban are separate groups but strong allies.
Tribal sources said 43 people, 20 of them members of the pro-government militant group Ansar ul-Islam, had been killed and more than two dozen wounded during two days of heavy fighting in Tirah.
The sources said the TTP and Lashkar-e-Islam militants had captured four important posts from members of the Ansar ul-Islam and advanced towards the strategically important Maidan area which is close to Bara subdivision, near Peshawar.
Peshawar is just 100 miles (160 km) east of Islamabad.
Pakistani troops were sent to fight alongside the tribesmen and Ansar ul-Islam to stop the fall of Bara, the sources said.
"Once Bara subdivision is captured by the militants, they would easily carry out attacks in Peshawar and that's why the government has been using all resources to foil the militants' attempt," Khayal Gul Afridi, a noted tribal elder, said in Bara.
Ihsanullah Ihsan, a spokesman for the Pakistani Taliban, said the group had inflicted heavy losses on their opponents and captured important positions.