Pakistan's Armed Forces Institute of Rehabilitation Medicine sees over 1,200 patients each day, some of whom are amputees. The hospital only began offering modern prosthetic limbs to these patients a few years ago. (Whitney Shefte/The Washington Post)

When 10 Pakistani soldiers tried to dislodge Taliban militants from a madrassa near the Afghan border this summer, their advance was crippled by relentless gunfire. Within minutes, two soldiers were dead, and Imran Ali had so many bullets in his legs he couldn’t tell whether they were still attached.

For 22 agonizing hours, Ali said, he curled up on the floor waiting for other soldiers to fight their way in to rescue him. After he was finally flown to safety, his left leg was amputated at the knee, and he became another victim of the Pakistani army’s latest offensive against Islamist militants in the restive tribal area of North Waziristan.

“I received so many bullets, I still can’t figure them all out,” Ali, 25, recalled recently at a military rehabilitation hospital in this city. “But this is for the survival of the country, and God willing, we are going to win this war.”

Ali is among nearly 800 Pakistani troops who have been wounded since the military launched its North Waziristan operation in June. Two hundred nineteen have been killed, adding to a toll of about 4,400 Pakistani troops who have lost their lives battling Islamist militants in northwestern Pakistan since 2002. That’s nearly twice as many troops as the United States lost in the same period in neighboring Afghanistan.

Now, two months after the Pakistani Taliban slaughtered 150 students and teachers at an army-run school in the city of Peshawar, military leaders are assessing just how much more blood will be spilled.

An amputee exercises at the Armed Forces Institute of Rehabilitation Medicine in Rawalpindi. The hospital sees about 1,200 patients each day, most of them members of the Pakistani military. (Whitney Shefte/The Washington Post)

Despite the growing resolve of Pakistani soldiers in their fight against Islamist extremism, military leaders here remain worried about diverting too many troops from their traditional mission of defending the eastern border with arch-foe India. But those concerns are tempered by fears that militants are evolving into smaller and more erratic groups that will be testing Pakistani forces for years — and perhaps decades.

In a recent interview, Defense Minister Khawaja Asif said he hopes the bulk of the fighting in North Waziristan will be over within “a few months.” But a senior Pakistani military official, speaking on the condition of anonymity because he was not authorized to talk to the news media, said current plans call for keeping as many as 170,000 soldiers — almost one-third of the entire force — near the Afghan border through at least 2019.

Such an extended presence would allow the military to safeguard recent gains in North Waziristan, which has long served as a base for al-Qaeda, while still being able to quickly respond to emerging threats, including efforts by Islamic State militants to gain a foothold in the region.

“We are now basically fighting for the defense of the subcontinent,” the official said. “It’s not only for Pakistan; it’s for all of South Asia. With the withdrawal of NATO from Afghanistan, the entire burden has fallen on Pakistan.”

Some analysts and U.S. officials are skeptical, however, that the Pakistani army can stomach a prolonged fight against Islamist militants, some of whom were nurtured by Pakistani defense and intelligence agencies as bulwarks against India and might still be viewed as assets. Other analysts say that even if the military fights stoutly, it is unclear whether it can win.

“This is a mission that may well be beyond their capability,” said Jonah Blank, a Pakistan expert at the Rand Corp. “The U.S., after 13 years in Afghanistan, has not been able to put the Taliban out of business . . . and that is the most powerful military the world has ever seen. So it may be unrealistic to expect that the Pakistani military could eliminate the Taliban or even reduce it to a bare-bones operation.”

Asif, the defense minister, said skeptics need to give the military time, perhaps two years, to prove its resolve.

“This is a menace the world has to face, and it’s not only in Pakistan,” Asif said. “The Middle East, North Africa, Europe — there are so many conflict areas, and the world has to take care of it and come to grips with it.”

Shaukat Qadir, a retired Pakistani army brigadier, said soldiers were deeply affected by the Taliban assault on the school in Peshawar. After years of half-hearted efforts to combat Islamist militant groups, Pakistani troops and commanders finally “feel this war is worth fighting,” Qadir said.

“You have to fight your own people, but nonetheless, they now know it needs to be done,” said Qadir, adding that troops are energized by the humble, hands-on leadership style of Pakistan’s powerful army chief, Raheel Sharif.

That resolve was evident at the Armed Forces Institute of Rehabilitation Medicine in Rawalpindi, a city adjacent to Islamabad, the capital. On a recent visit to one ward, a dozen soldiers in crisp blue hospital gowns, many of them missing limbs, were seen sitting up in their beds.

“I am very much hopeful that, yes, things are getting better, and we will win this war,” said Muhammad Rafiq, 19, who lost a foot when he stepped on a bomb in the tribal area of South Waziristan, where troops are also deployed. “We are very much into it, and the whole nation is now into it.”

The injured soldiers said they were surprised, however, to be battling an enemy far different from the one they had expected to meet when they enlisted.

“All of the thinking of India being the enemy for this country, I felt it, too, when I joined the army,” said Talat Mehmood, 30, who lost his right leg while fighting in South Waziristan two years ago. “But this new enemy is equally dangerous, equally dreadful, and needs to be taken care of.”

As more troops are injured, they often show up here at the rehabilitation hospital. Considered Pakistan’s version of the Walter Reed National Military Medical Center in Bethesda, Md., the hospital opened in 2005. It recently expanded from 100 to 150 beds to treat an influx of wounded soldiers, officials said.

During past Pakistani military conflicts, injured soldiers were fitted with wooden prostheses that wobbled under use. Now, in a basement workshop at the hospital, technicians sculpt temporary plaster prosthetics by hand. The hospital increasingly provides patients with flexible plastic and metal prosthetics common in the West.

It is also branching out to offer speech therapy as well as occupational and traumatic brain--injury therapy.

“We are trying to say to these soldiers who have been injured that they can remain a useful part of society,” said Col. Khalid Siddiqui, a specialist at the hospital.

But Maj. Gen. Akhtar Waheed, who heads the hospital, said it might be decades before the army truly recovers from its battle against militants. He noted that Pakistan, a country that is intensely proud of its armed forces, provides lifetime care to wounded soldiers.

“This population is 19, 20, 25 years old, and they have to live another 40 or 50 years,” Waheed said. “Once you have sacrificed for your country, even if it’s an injury to their fingertip, we have to take care of them.”