Earlier in the week, Afghan authorities accused Pakistan of bombing the capital, Kabul, and a market in the country's east. Pakistan did not claim responsibility for the assault.
The Taliban government's chief spokesman, Zabihullah Mujahid, said Afghan forces captured 25 Pakistani army posts and wounded 30 soldiers overnight.
"The situation on all official borders and de facto lines of Afghanistan is under complete control, and illegal activities have been largely prevented," Mujahid told a press conference in Kabul.
There was no immediate confirmation from Pakistan about casualties.
The Taliban government's defence ministry said its forces had conducted "retaliatory and successful operations" along the border.
"If the opposing side again violates Afghanistan's territorial integrity, our armed forces are fully prepared to defend the nation's borders and will deliver a strong response," the ministry added.
The Torkham border crossing, one of two main trade routes between the two countries, did not open on Sunday at its usual time of 8am.
Pakistan accuses Afghan authorities of harbouring members of the banned group Tehreek-i-Taliban Pakistan.
Islamabad says the group carries out deadly attacks inside Pakistan, but Kabul denies the charge, saying it does not allow its territory to be used against other countries.
Pakistani Prime Minister Shehbaz Sharif condemned the overnight assault and said the country's army "not only gave a befitting reply to Afghanistan's provocations but also destroyed several of their posts, forcing them to retreat."
Qatar's Foreign Ministry expressed concern over the escalations and the potential repercussions for the security and stability of the region. It urged both sides to prioritise "dialogue, diplomacy and restraint."
The Saudi Foreign Ministry issued a statement calling for "restraint, avoidance of escalation and the adoption of dialogue and wisdom to help de-escalate tensions and maintain the security and stability of the region."
A senior Pakistani security official, speaking on condition of anonymity, said Afghan forces opened fire in several northwestern border areas in the province of Khyber Pakhtunkhwa, including the districts of Chitral, Bajaur, Mohmand, Angoor Adda and Kurram.
The official also said troops responded with heavy weaponry near Tirah in Khyber district and across the frontier in Afghanistan's Nangarhar province.
The two countries share a 2611km border known as the Durand Line, but Afghanistan has never recognised it.