Pakistan's military said a "group of terrorists" staged a rocket attack from across the Afghan border Sunday, killing four soldiers and wounding four others.
The incident happened in Pakistan's northwestern Khyber tribal region that borders eastern Afghanistan.
"Rounds fired from Afghanistan side by terrorists hit an 8,000 feet high Pakistani post in Akhandwal Pass. Pakistani troops befittingly responded and eliminated the group of terrorists," the military's media wing said in a statement.
Pakistan's Foreign Ministry summoned Afghan Ambassador Janan Mosazai to protest the cross border attack.
The ministry said the Afghan ambassador expressed his condolences for the killing of the Pakistani soldiers and said he would convey Islamabad's request for an investigation to Kabul.
Pakistan complains that fugitive insurgents linked to the Pakistani Taliban have taken refuge in Afghanistan border areas from where they plan and stage cross-border raids.
Khyber serves as one of the main trade and transit routes between Pakistan and Afghanistan, where Pakistani Taliban an other militant groups used to have strong bases.
However, an ongoing military offensive is said to have cleared most of the area of insurgents and officials say only a few pockets located in difficult mountainous areas have yet to be eliminated.
Afghan authorities have not yet commented on the border clash.
The two countries have in recent days also accused each other's forces of initiating cross border shelling.
Last week Islamabad summoned the Afghan ambassador to register protest over "unprovoked" shelling that killed three Pakistani soldiers.
A day earlier, Kabul had summoned the Pakistani envoy in the country to inform him that Islamabad initiated the conflict that killed eight Afghan soldiers.