PESHAWAR, Pakistan (Reuters) - Pakistan said on Monday it would open border crossings for two days to allow through Afghans with valid visas after Islamabad shut the frontier because it said militants accused of a series of attacks were being sheltered in the neighboring country.

Relations between the countries are tense, and each routinely accuses the other of doing too little to prevent Taliban fighters and other militants from operating in its territory.

Pakistan has blamed the attacks last month, in which more than 130 people were killed, on Pakistani militants taking shelter in Afghanistan. Afghanistan denies the charges.

In response, Islamabad shut down border crossings and asked Kabul to hand over wanted militants believed to be hiding on the Afghan side.

“In order to provide an opportunity to those nationals of Afghanistan who had come to Pakistan on valid visas, and wish to return to their country, the government of Pakistan has decided to open the border crossings at Torkham and Chaman on 7th & 8th March 2017,” the Foreign Office said in a statement.

The border will also be opened for two days for Pakistanis who traveled to Afghanistan on valid visas and wish to return.

In one such attack, Pakistan’s military said on Monday five Pakistani soldiers were killed in attacks on northwestern border checkpoints launched by militants based in Afghanistan.

Dozens of militants from across the border stormed security posts ‎in Pakistan’s Mohmand Agency district on Sunday night, said senior security officials based in the region.

Pakistan’s military said 10 militants were killed in an exchange of fire and asked Afghan authorities to strengthen surveillance in border areas.

The Afghan government had no immediate response to the Pakistani statements.

Asad Mansoor, a spokesman for Jamaat-ur-Ahrar, a splinter faction of the Pakistani Taliban, claimed responsibility, saying it was part of a campaign launched last month to target “enemies of Islam” across Pakistan.

Pakistan summoned the deputy head of the Afghan embassy in Islamabad to protest against the raid, the Foreign Office said on Monday, urging Afghanistan to crack down on militants operating on its side of the border.

The Tehreek e Taliban Pakistan - a grouping separate from but allied with the Afghan Taliban - has been fighting for years to overthrow Pakistan’s democratically elected government and impose strict Islamic law on the nation of 190 million.