The Pakistan military says that two soldiers were killed and three injured by rockets fired from Afghanistan early on Wednesday.
"Pakistan condemns these unprovoked attacks. This matter has been raised with the Afghan government in Kabul and with their embassy in Islamabad," the Pakistan foreign ministry said.
A foreign ministry spokesperson said it has been emphasised that Afghanistan must take concrete steps to stop the use of its territory against Pakistan, Xinhua reported.
"For its part, Pakistan remains committed to supporting all efforts for peace and stability in Afghanistan," the spokesperson said in a statement.
Giving details of the Wednesday attack, the foreign ministry said two Pakistani border posts, Manozangal and Moukha in Bajaur Agency, were attacked by terrorists from across Afghanistan.
"As a result of this unprovoked firing, two Pakistani soldiers were martyred and three others, including one officer, were injured."
The foreign ministry said it was the third incident of cross-border attacks in the last 10 days.
There was no immediate reaction from the Afghan side of the border.
On Sunday, the Pakistani military said nearly 200 Pakistani Taliban fighters, who officials say now operate from Afghan soil, launched attacks on Pakistani border posts in Bajaur tribal region, killing one soldier and injuring several others.
In retaliation, Pakistani forces had killed 16 militants, according to the army.
Afghan officials said that Pakistani rockets had also killed six people on the same day in eastern Kunar province.
Zahir Azimi, spokesman of the Afghan defence ministry, also said Sunday that Pakistani helicopters crossed the border and flew over Kunar.
Both countries have also lodged formal protests over the cross-border attacks.
The attacks occurred at a time when cooperation between the two countries is needed for the peaceful presidential election runoff in Afghanistan in June.