TORKHAM: Thousands of stranded Afghans and Pakistanis returned home on Tuesday as Pakistan temporarily reopened two main crossings that had been closed last month after a wave of militant attacks, officials said.

The Torkham and Chaman crossings were to remain open through Wednesday for nationals from both countries with valid visas who want to return home, a measure intended to calm tensions and ease a backlog.

Nearly 5,000 Afghans left for their country and another 1,500 Pakistanis crossed in the opposite direction, said Fayyaz Khan, a Pakistani official at the Torkham crossing. He said overland trade between the two countries has 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, a 52-year-old Afghan, told The Associated Press as he and his family waited at a checkpoint.

Pakistan shut the crossings three weeks ago after a wave of suicide bombings that authorities said was linked to Islamic militants based in Afghanistan. The two countries have long accused each other of ignoring al-Qaida and other militants who operate along the porous, mountainous border.

Khairullah Azad, the deputy spokesman for the Afghan Foreign Ministry, urged Pakistan to restore normal movement at the crossings, saying the two-day reopening was insufficient for people living on both sides of the frontier.

The opening of the crossings came a day after Pakistan said a group of militants crossed over from Afghanistan and attacked several military posts, setting off clashes that killed six soldiers and 10 militants. It said it had complained about the attack to Kabul and called on Afghanistan to take action.

Meanwhile, at least two Pakistani soldiers and five militants were killed Tuesday in the northwestern town of Swabi during a raid on a militant hideout, the military said. It provided no further details, saying the fighting was still underway. The Pakistani Taliban claimed it attacked soldiers in Swabi.-AP