Internally displaced Pakistanis, fleeing a military operation in the North Waziristan tribal agency, wait in line outside a World Food Programme aid distribution centre in Bannu on June 25, 2014. (A Majeed/AFP/Getty Images)

Pakistan has evacuated more than 450,000 civilians from a terrorist-plagued district in the northwestern part of the country, but its offensive against the militants there is complicated by fresh tension with neighboring Afghanistan.

With the North Waziristan campaign in its second week, officials say most civilians have left the remote, mountainous area, home to thousands of militants affiliated with the Pakistani Taliban and groups such as the Haqqani network. More than 350 militants have been killed, and military commanders say a full-scale ground invasion is imminent.

The area’s porous border with Afghanistan makes it likely, however, that some militants have escaped. Pakistan says Afghanistan is not doing enough to bolster surveillance of its side of the border. Pakistani Taliban leader Mullah Fazlullah is thought to live in Afghanistan, and Pakistani Prime Minister Nawaz Sharif has personally appealed to Afghan President Hamid Karzai to help dislodge him.

“So far, there has been no action on the part of the Afghan government to dismantle [Pakistani Taliban] hideouts,” said Pakistani Maj. Gen. Asim Bajwa. “We want them to take action.”

In recent days, Afghan commanders have been largely dismissive of such concerns, saying they are doing all they can to help their Pakistani counterparts.

Men carry a person who fainted while queuing up to receive food supplies at a distribution point for those fleeing the military offensive against militants in North Waziristan, in Bannu, Khyber-Pakhtunkhwa province. (Stringer/Reuters)

Karzai’s security forces have been locked in a nearly week-long battle with hundreds of Afghan Taliban militants in the southern province of Helmand. On Thursday, Afghan officials accused Pakistani military and intelligence officials of supporting the Afghan militants.

“From a security point of view, we have taken all necessary measures to make sure that combatants, destructive elements and intelligence infiltrators are not amongst the refugees who have come to this side” of the border, said Abdul Hasib Seddiqi, a spokesman for the Afghan National Directorate of Security. “There is no Pakistani Taliban leader or group that operates in Afghanistan . . . Pakistan makes such accusations in order to justify its rocket attacks on our soil.”

U.S. officials have been stymied for years in their efforts to get Pakistan and Afghanistan to work together to combat border terrorists. The challenge is taking on more urgency as American forces continue to draw down in Afghanistan.

The Pakistani Taliban and the Afghan Taliban claim to be independent of each other, but they are thought to coordinate some activities. For years, military and intelligence officials on both sides have traded accusations of secretly supporting the other country’s Taliban group.

“Afghan intelligence is full of anti-Pakistani people, and so is the top leadership of the Afghan army, so why would they help Pakistan?” asked retired Gen. Javed Ashraf Qazi, a former head of Pakistan’s Inter-Services Intelligence agency.

The military launched the North Waziristan assault June 15 after a brazen attack by the Pakistani Taliban on Karachi’s airport about a week earlier.

Unlike in some previous military operations, Unlike in some previous military operations, officials insist that the ongoing offensive will target not only the Pakistani Taliban but also the Haqqani network, which has been linked to attacks on U.S. troops in Afghanistan.

The network is suspected of past ties to Pakistani intelligence agencies. But last week, Gen. Rashad Mahmood, chairman of Pakistan’s Joint Chiefs of Staff Committee, repeatedly stressed to Pentagon leaders and U.S. lawmakers that the Haqqani network will be driven out of North Waziristan in the operation.

“The army is saying, and the impression everyone is carrying is, they are going to go all the way this time,” said Shaukat Qadir, a retired Pakistani army brigadier who maintains close contact with active-duty leaders. “And by all the way, that means everybody — everybody we didn’t like and everybody we did like.”

The military’s anti-Taliban campaign in the Swat Valley in the late 2000s has served as a blueprint for the current offensive. As in Swat, the first phase of this offensive involved evacuating civilians. About 456,000 Pakistanis have left, most resettling in nearby Khyber Pakhtunkhwa province or other parts of Pakistan.

At least 65,000 have moved to Afghanistan’s Khost province, according to the United Nations.

Recent interviews with some of the displaced residents suggest that many militants also have fled the area.

“The operation seems to be against the people of Waziristan and empty houses, as the jet fighters are bombing empty spaces because there are no militants left,” said Gul Zaman, 35, a schoolteacher from North Waziristan.

But Bajwa said careful screening has “trapped” militants who have tried to escape. Analysts remain skeptical.

This week, Afghan Defense Minister Bismillah Khan Mohammadi accused Pakistan of sending plainclothes agents into Afghanistan’s Konar province who carried out attacks that killed Afghan troops and civilians.

Pakistan’s Foreign Ministry denied the allegations. To resolve the tension, Karzai’s national security adviser traveled to Islamabad on Thursday and met with Sharif and other top Pakistani officials.

Sayed Salahuddin in Kabul and Haq Nawaz Khan in Peshawar, Pakistan, contributed to this report.