Pakistan has temporarily reopened its two main border crossings with Afghanistan to allow visitors with valid visas on both sides to return home, the foreign office announced.

Pakistan sealed the Torkham and Chaman crossings on February 16, after a string of suicide attacks killed more than 130 people across the country, blaming the violence on Tehreek-e-Taliban Pakistan and other armed groups.

"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 March 7 and 8," the foreign office said in a statement.

The temporary opening was for people who had travelled for medical, work and business purposes but were left stranded, according to Afghan ambassador to Pakistan, Omar Zakhilwal.

"Many people were running out of money and were in a miserable state on this side [Pakistan] of the border," Zakhilwal told Al Jazeera.

"They wanted to go back to Afghanistan but were stuck after the borders were shut," he said, adding that arrangements were being made to airlift them if the border crossing remained shut.

Fayyaz Khan, a Pakistani official at Torkham, said large numbers of Afghans were returning home, along with smaller groups of Pakistanis, but that overland trade between the two countries was yet to resume.

"I have a valid visa and I promise that I will never come back here. Please allow me go back to my country," Matiullah Khan, 52, told The Associated Press as he and his family waited at a checkpoint.

Afghanistan has long blamed Pakistan for providing sanctuary to Afghan Taliban and Haqqani Network leaders on its soil, while Pakistan accuses its northwestern neighbour of allowing Pakistani Taliban elements to operate in Nangarhar and other provinces.

Jamaat-ul-Ahrar, a Pakistani Taliban breakaway faction, had claimed responsibility for the recent attacks, including Monday's targeting of three Pakistani posts in the Mohmand tribal area on the Pakistan-Afghanistan border that left at least 15 people dead.

READ MORE: Afghan refugees return home amid Pakistan crackdown

In February, the two countries exchanged lists of fighters they believed to be residing in each other's countries.

On Monday, Pakistan Minister of Defence Khwaja Asif claimed the border was being used "as a thoroughfare" by Pakistani Taliban fighters.

"Our murderers are sitting on their border and you are pleading us not to close down the borders," he said at a session of the National Assembly.

"We want to have a proper border management with Afghanistan like all the countries have with their neighbouring countries. We will not allow [the border] to be used as a thoroughfare."

'Ready to go after threats'

But Zakhilwal argued that closing down the border served no purpose "except to harm ordinary people and traders on both sides".

"The areas near the border are heavily guarded with army, intelligence and police checkpoints, so it does not make sense there could be any movement of terrorists along the borders," he said.

"The closure is just to inflict pressure on Afghanistan but we insist that we are ready to go after threats and propose a logical and a realistic approach to fight terrorism. Closing the border has no connection to fighting terrorism."

Torkham and Chaman crossings are major arteries for the $1.5bn in trade and commerce between the two neighbours. The Torkham crossing is used by about 15,000 Afghans every day.

Other crossings, which are generally less used, will remain closed.

With reporting by Shereena Qazi: @Shereenaqazi