By Zia Ur Rehman and Declan Walsh 

JULY 26, 2014

SWAT VALLEY, Pakistan — As battle rages in North Waziristan, where the Pakistani military says it has killed more than 500 militants, unfinished business from the army’s first major assault on the Taliban lingers painfully in the Swat Valley, at the other end of Pakistan’s Pashtun belt.

Five years ago, Pakistani soldiers flooded into Swat as part of an operation to banish the Taliban from the valley. The offensive became a cherished victory for Pakistani generals, who presented it as evidence of their counterinsurgency prowess.

But a steady drumbeat of killings, by both militants and soldiers, has whipped up fear in Swat in recent years and blighted hopes for a return to normality in a place known for its beauty and tourist industry. Taliban fighters have slowly crept back to attack and kill pro-government community leaders. The army faces accusations of gross human rights abuses, including the execution of at least dozens of detainees whose bodies have recently been returned to their families.

These child refugees seek to escape the fighting between the military and Islamist militants, but the violence is spreading.

And Maulana Fazlullah, the ruthless cleric and militant commander who led the original Swat uprising in 2007, has evaded capture and risen to greater heights as the supreme leader of the Pakistani Taliban.

“For a long time there was a narrative of the Swat operation as a total success,” said Rahimullah Yousafzai, a veteran journalist based in Peshawar. “Now that success is being questioned.”

Few doubt that conditions in Swat have improved dramatically. Bloodied bodies no longer hang from traffic lights in the town square where the Taliban once executed their enemies. Markets are bustling, and more girls are attending school.

But the campaign of Taliban violence, though sporadic, has rattled public confidence. “This is a controlled peace,” said Akbar Khan, a 38-year-old bookseller. And it offers a sobering check on the limits of military engagement at a time when the army is engaged in a fresh anti-Taliban drive in the tribal district of North Waziristan.

There, more than one million people have fled their homes since the operation started on June 15. The military, which tightly controls media access, has portrayed it as an unalloyed success, drip-feeding reports of battlefield victories to the Pakistani media. On Saturday, a spokesman said its forces had killed 531 militants and lost just 34 men.

Similarly triumphant claims followed the 2009 Swat offensive, but some successes proved to be temporary. Although hundreds of Taliban fighters were captured, many more slipped across the porous border into the Afghan provinces of Kunar and Nuristan, where they have successfully regrouped.

In the last two years, small pockets of fighters have infiltrated back into Swat, moving along remote mountain trails on horseback and on foot, according to villagers.

One of their most infamous attacks was on Malala Yousafzai, the teenage schoolgirl who was shot in the head in October 2012 but survived her injuries and became a global icon.

But for the most part, the Taliban gunmen have targeted the Village Defense Committees — local militias, mounted by the army to keep the Taliban at bay — which lost nine leaders to Taliban attacks in 2013, and eight so far this year. In the most recent shooting, on Tuesday, gunmen opened fire on Umar Hayat Khan, the committee leader in Takhta Band village, as he said his prayers in a local mosque.

Two weeks earlier, gunmen killed Khan Saib, a landowner who had just returned from self-imposed exile in Saudi Arabia. A relative said that Mr. Saib had fled Swat after the Taliban demolished his house in 2009, and had been attacked twice before his death.

The shootings have scared Swat residents because their targets are prominent community leaders — often landowners or members of the Awami National Party, a secular party that has borne the brunt of Taliban violence across Khyber-Pakhtunkhwa Province.

The army itself has been another cause of concern in Swat as it has cast a wide net for militants.

Human-rights groups say that hundreds of suspected militants have died in military custody since 2009. In 2010, Gen. Ashfaq Parvez Kayani, then the army chief, announced an investigation into a video that appeared to show soldiers executing six detainees. The result of the investigation was never made public; some activists questioned whether it ever took place.

Since April 2013, some Swat detainees have turned up dead, their bodies quietly returned to their families for burial. Many have reportedly been held in an army-run internment center in Kohat, 30 miles south of Peshawar. Relatives say the army often attributes the deaths to heart attacks — an explanation that human-rights activists say is consistent with similar violations elsewhere in northwestern Pakistan.

“Most of these detainees are in their 20s or early 30s. It’s unusual for men of that age to die from a heart attack,” said Mustafa Qadri of Amnesty International. In Swat, the wives and children of detained men hold regular protests against the military. The most recent took place on July 20 in the village of Kanju, where women waved photos and held placards calling for judicial intervention. “Let the courts decide if they are guilty,” read one.

While mistreatment of detainees offends rights groups, many Swat residents have a more ambivalent attitude, said Mr. Yousafzai, the journalist. “The community is very polarized,” he said. “Many people don’t want to hear about the suffering of militants or their families.”

Public opinion had been further divided by plans for three permanent military bases in Swat. Some citizens want the army to leave; others fear a return to civilian rule would lead to a Taliban resurgence. “People remember that the last time, the civilians ran away,” Mr. Yousafzai said.

The tensions and violence have stymied efforts to revive the local economy, despite some progress. The valley’s ski resort at Malam Jabba, which had been destroyed by the Taliban, hosted a five-day “snow festival” in March; a summer festival is scheduled for early August. The valley’s musicians and dancers have returned from the cities where they fled in 2009.

But caution is widespread. Kiran, a dancer who would give only her first name, said she refused to work outside the main town, Mingora. Some business owners have left the valley over security fears. And tourism numbers are way down, said Zahid Khan, head of the Swat hotel owners’ association.

Meanwhile, Mr. Fazlullah, the Taliban leader, is using his Afghan sanctuary to step up the pressure. His fighters killed a two-star general, Maj. Gen. Sanaullah Khan Niazi, in a roadside bombing in neighboring Dir district in September 2013. His fighters have infiltrated Karachi, the port city where they run a campaign of extortion and assassination targeting Pashtun political and business leaders.

More recently, Mr. Fazlullah has increased violence inside Swat in a bid to shore up his authority inside the Taliban, following a split in the militant ranks last May. In a rare video message released on May 19, he directed suicide bombers to attack “the forces of evil.” The military, for its part, is focused on the campaign in North Waziristan. But that has also touched Swat, in the form of refugees who have made an arduous journey across northwestern Pakistan to the verdant valley in search of shelter.

The authorities in Swat have registered almost 600 refugees from Waziristan, many of whom are living in cramped rented accommodations.

Speaking at a religious charity’s food distribution event, Hajji Nooruddin, a 50-year-old truck driver from Miram Shah, said he was sharing a house with 25 other people.

Asif Nawaz, 21, said he was stuck in a traffic jam for two days as he fled North Waziristan. During that time, he saw two mothers take the bodies of their dead infants to the soldiers, shouting that they had died from hunger, he said with tears in his eyes.

However, many of the refugees said they were glad to have reached Swat — a place of relative safety, compared with North Waziristan.

An employee of The New York Times contributed reporting from the Swat District in Pakistan.