TORKHAM, Pakistan — Above the trucks and travelers lining up at the main eastern gateway between Afghanistan and Pakistan, a glinting new landmark scales the dun-colored mountains: Parallel mesh fences, a couple of feet apart and topped with coils of razor wire, climb from the border crossing up over the dizzying crags.
The section of fence overlooking Torkham is just a glimpse of a 1,600-mile barrier begun four years ago by Pakistan’s military and set to be completed this year.
Nearly 9,000 miles from President Trump’s border wall with Mexico, Pakistan has quietly been building its own version to try to control what has long been one of the world’s most porous and lawless frontiers.
The Pakistani Army credits the fence with helping to transform security in the country, sharply cutting terrorist attacks after a sustained army offensive pushed many militants — and tens of thousands of civilian refugees — into Afghanistan.
Yet the barrier is also a projection of hard power in its own right, to the detriment of diplomacy with Afghanistan and the life of Pashtun tribes that had functionally ignored the border for generations.
Afghanistan disputes the border that the fence follows, drawn by British colonial officials in 1893 and known as the Durand Line. And as the wire unfurls over hundreds of miles, it is cutting off routes through the mountains used by smugglers, militants, traders and families alike, according to interviews with government officials, tribal leaders and diplomats.
Pakistan had long considered a border barrier. But construction began in earnest in 2016, after costly army offensives to push many militants out of the country’s tribal areas and into Afghanistan.
Some 800 miles of the $450 million fence are now complete and more than 1,000 border forts are being built, according to a statement from the Pakistani military’s information wing. The route takes it through forbidding mountains where rockfalls, avalanches and landslides cause constant damage.
The vast majority of the work has been out of view of the public or other governments. One senior Pakistani security official, speaking on condition of anonymity because he was not authorized to brief the public, said, “It’s a herculean task because of the terrain up there.”
Despite that difficulty, senior officers say it has had an appreciable effect on security even though it has not been finished. They cite a sharp drop in attacks by militants linked to the Pakistani Taliban, known as Tehrik-e-Taliban, after many were driven into Afghanistan.
Last year only 82 attacks in Pakistan were attributed to that network, down from 352 in 2014, when the military offensive began, according to the Islamabad-based Pak Institute for Peace Studies, which monitors extremist violence.
The difficulties of maintaining the fence and keeping watch to see that it is not being breached have led some diplomats to question how practical it will be without high-tech assistance like cameras or other surveillance.
Pakistan’s military said in a statement that the fence was strengthened with “surveillance and intrusion detection systems,” as well as border forts, but gave no further details.
“Security is much better,” one Pakistani security officer said. “But you can’t do everything with a fence. People will still come through. They look like the local population, and they live among them.”
But in recent months, there have been increasing reports that some Pakistani Taliban fighters have managed to come back to some of the tribal areas in the northwest. Last Monday at least three people, including a Pakistani colonel, were killed in a shootout between soldiers and militants in Tank district, near South Waziristan.
Fence construction groups have also been attacked by militants, who have released videos of themselves tearing down sections and seizing building supplies.
Corruption and bribery are also likely to help people find ways through in a region where smuggling has been a way of life for many.
The fence may slow down illegal crossings, but it will not stop them entirely, said Elizabeth Threlkeld, an American diplomat in the border city of Peshawar until 2016 and now with the Stimson Center, a Washington-based think tank that focuses on foreign policy.
“Many of those determined to cross, including both militants and local residents whose livelihoods depend on smuggling, will find a way,” Ms. Threlkeld said. “The greater impact of the fence will instead be on Pashtun communities spanning the border, who will lose the ability to cross freely to visit family or do business.”
Cross-border trails and roads were once common in the mountains on either side of Torkham, many of them without checkpoints.
Zahid Shinwari, a former chairman of the chamber of commerce for Khyber Pakhtunkhwa Province, where the Torkham crossing is, said that traders bound for bazaars, or families visiting relatives, had thought little of the frontier and were used to passing without paperwork checks.
Those informal routes have now been closed, forcing all traffic through controlled border crossings. Eventually, Pakistan’s military plans 16 “notified routes” to cross along the length of the new fence, officials said.
“All the crossings have been declared illegal; there were many, many. It’s a major change,” Mr. Shinwari said.
“We actually didn’t consider the Afghanistan side as some other country, like traveling to Europe or the Arab countries,” he added. “It was very common that a few friends used to plan a trip to Jalalabad in the morning and we would sit in a car, cross the border, have lunch in Jalalabad and come back. This tradition has been stopped.”
Each day, children in orange tunics line up at the Torkham crossing to get to the Pakistani side from Afghanistan to school, showing how close the links remain. But the fence has been accompanied by tightening immigration rules. Travelers now need passports and visas to cross, and lines at embassies in Kabul and Islamabad have sharply lengthened. Much to their anger, traders must pay customs fees.
The fence has also angered Afghanistan. It accuses Pakistan of rushing through the new barrier to cement its claim on the Durand Line border while Afghanistan is preoccupied with fighting the Afghan Taliban insurgency, which was nurtured on the Pakistani side.
Fence-building has become a flash point, with the appearance of construction crews sometimes inciting firefights and occasional shelling. Afghan troops have accused Pakistan of building on Afghan territory.
Both Afghan and Pakistani officials said clashes along the border had increased as the fencing progressed, without giving numbers. One Torkham official pointed out the spot where he said a Pakistani Army major was killed by Afghan shelling in June 2016.
The Pakistani military declined to say whether the fence was considered permanent. One Pakistani politician said he had been assured by a senior officer that it was not going to be “another Great Wall of China.”
Yet for the tribes and families with feet on either side, the new barrier is already having an effect on their social fabric. As travel has become more difficult, families have started to move, forced to make a choice about which side to consolidate households in.
“The question will be in the longer term, is it going to have a real social and cultural impact on this area,” said Muhammad Amir Rana, the director of the Pak Institute for Peace Studies. “This is segregating the population, the tribes from both sides. This process is going on.”