Key border crossings between Pakistan and Afghanistan were closed on Sunday after fierce clashes erupted overnight following Taliban accusations that Islamabad had carried out air strikes this week, officials said.

Neighboring Afghanistan and Pakistan have had frosty relations since the Taliban returned to power in Kabul in 2021. Islamabad accuses authorities there of harboring militants carrying out strikes on its soil, an accusation Afghanistan denies.

Afghanistan's Taliban forces attacked Pakistani soldiers along their shared border on Saturday night, accusing Islamabad of violating its sovereignty after explosions were heard in Kabul and in the southeast two days earlier.

Officials from both sides of the border said that crossings at Torkham, which connects Pakistan's Khyber Pakhtunkhwa province with Nangarhar in Afghanistan, and Chaman, more than 800 kilometers to the southwest, were closed.

Pakistani Prime Minister Shebaz Sharif condemned what he said were "provocations by Afghanistan" along Pakistan's border area overnight.

"There will be no compromise on Pakistan's defense, and every provocation will be met with a strong and effective response," Sharif said in a statement, accusing Taliban authorities in Afghanistan of allowing their land to be used by "terrorist elements."

A senior Pakistani official in Torkham said extra paramilitary troops had been sent to the area, which sits on the border between Kabul and Islamabad.

"The Torkham border has been completely closed for pedestrian movement and trade," said the official, who spoke on condition of anonymity because he was not authorized to speak to the media.

"Security forces have also pulled out all civilian staff posted at the border, so they are not harmed in case of further firing," he said.

Another Pakistani border official at Chaman, which links Balochistan province with Kandahar, the birthplace of the Afghan Taliban, said the crossing was "sealed."

Other Pakistani officials said there had been clashes using heavy weapons in at least four border districts but there had been no casualties on its side.

The Afghan military said on Saturday night Taliban forces were engaged "in heavy clashes against Pakistani security forces in various areas."

Taliban defense ministry spokesman Enayat Khowarazm later said that the "successful" operations had ended at midnight.

Several border security officials said that no further clashes had been reported on Sunday morning.

Militancy has surged in Khyber Pakhtunkhwa since the withdrawal of U.S.-led troops from neighboring Afghanistan in 2021 and the return of the Taliban government.

The militant organization Tehrik-e-Taliban Pakistan (TTP) and its allies are accused by Islamabad of killing hundreds of its soldiers since 2021. TTP is separate from the Afghan Taliban, but it shares the same ideology and its fighters are trained in combat in Afghanistan.

Islamabad has not confirmed that it was behind Thursday's strikes that sparked the border clashes.

Saudi Arabia, Iran and Qatar have urged both sides to "exercise restraint."

TTP militants have intensified their campaign of violence against Pakistani security forces in the mountainous areas bordering Afghanistan in recent months.

More than 500 people, including 311 troops and 73 policemen, have been killed in attacks between January and Sept. 15, a military spokesman said on Friday.

A U.N. report this year said the TTP "receive substantial logistical and operational support from the de facto authorities," referring to the Taliban government in Kabul.

Khawaja Muhammad Asif, Pakistan's defense minister, told parliament on Thursday that several efforts to convince the Afghan Taliban to stop backing the TTP had failed.

"Enough is enough," he said. "The Pakistani government and army's patience has run out."