QUETTA, Pakistan (AP) — A group of militants in Afghanistan fired across the border at troops in southwestern Pakistan on Wednesday, killing at least four soldiers before fleeing, the military said. Three other troops were killed in a shootout with militants in the country’s northwest.

The border attack took place as a Pakistani unit was overseeing fencing installations near the town of Zhob in Baluchistan province, the military said in a statement. It said the troops returned fire; six soldiers were also wounded and transported to a hospital in Quetta.

No one claimed responsibility for the attack and the military provided no further details.

Pakistan’s foreign ministry condemned the attack, saying it involved 20 militants. The statement said such attacks are detrimental to ongoing peace and stability efforts along the Pakistan-Afghanistan border. It added that Islamabad asked Kabul through diplomatic channels to take measures to avoid such attacks in the future.

The shootout in the northwest occurred as Pakistani security forces raided a militant hideout in a former insurgent stronghold. Three soldiers and two insurgents were killed, the military said. The raid took place in North Waziristan, a district in Khyber Pakhtunkhwa province. The district served as a headquarters of the Pakistani Taliban until the military secured it in 2015 with a series of operations. Lately, insurgents have been regrouping there.

Pakistan started putting up a fence along the Afghan border in 2017 to contain militant movement and to curb smuggling and illegal border crossing. Pakistan says it has completed about 85% of the fence along the 2,611-kilometer (1,622-mile) boundary with Afghanistan that’s known as the Durand Line.

Kabul has never recognized the border, which runs through the Pashtun heartland, diluting the power of Afghanistan’s largest ethnic group on both sides. The two sides often accuse each other of tacitly allowing militants to operate along the porous frontier.