KABUL, Afghanistan -- The prisoner perched on a metal chair, hugging his knees to his chest and rocking slightly, like a nervous child.

But his expression relaxed into a blissful smile as he described what he would do if released from his cell in the headquarters of the national intelligence service.

"When I get the chance, I will stick to my promise," said Sher Ali, 28, a Pakistani man with cropped black hair and a long beard. "I will go to do jihad again and again."

Ali said he took his vow to wage holy war against U.S. forces in Afghanistan earlier this summer, just before embarking on what he described as a 20-day weapons training course at a secret mountain camp in northeastern Pakistan.

He was captured by Afghan police about three weeks ago, shortly after crossing into Afghanistan's rugged, northeastern Konar province. The area has been a haven for armed renegades from an assortment of groups, including al Qaeda, the Taliban and backers of former Afghan leader Gulbuddin Hekmatyar, who is now a fugitive.

Over the last several months, insurgents have killed hundreds of people in Afghanistan, including aid workers, religious and tribal leaders, government officials, and Afghan and U.S. troops, many in ambushes and bombings apparently aimed at derailing parliamentary elections scheduled for Sept. 18.

American and Afghan forces have countered with an aggressive effort to flush the fighters from their remote mountain hideouts, killing several hundred in operations in border provinces from Konar in the north to Kandahar in the south. They have also taken several hundred suspected insurgents prisoner and allowed a few to speak to journalists.

Ali's story, which could not be verified independently, offered a glimpse of what Afghan authorities charge is a shadowy Pakistani network that continues to fuel the insurgency with fresh recruits as fast as U.S. and Afghan forces kill or capture their predecessors.

Ali spoke in the presence of an Afghan intelligence official, but he did not show signs of having been mistreated. Some details, such as the existence of jihadist training camps and the recruitment of Islamic fighters, have been reported separately in the Pakistani press or described by prisoners after their release.

"We know where a lot of these training camps are. We have their names. And we've given the Pakistanis all the information we have," said a senior Afghan intelligence official. "We're waiting for Pakistan to show the willingness to fight."

Pakistan's president, Gen. Pervez Musharraf, has repeatedly pointed out that his government has captured or killed more than 700 suspected al Qaeda members in Pakistan since 2001. It also lost more than 250 soldiers last year in battles against al Qaeda bases in the largely lawless semiautonomous tribal regions along the Afghan border.

Officials from the two governments have recently exchanged pledges to collaborate closely on security. But they must still contend with the sympathy that many Pakistanis feel toward the Taliban, particularly in tribal border towns such as Miram Shah, where residents share the same Pashtun ethnicity as the Afghan militia.

It was in Miram Shah this summer, at the home of a friend, that Sher Ali said he met Zubair, an Afghan in his late twenties, who recruited him to fight in Afghanistan. Ali, who was visiting from his village, said Zubair did not initially admit to being an insurgent. "But from the way he talked, I could tell that he had been a fighter," Ali said during an hour-long interview in the intelligence headquarters.

Ali said Zubair told him and his companions that Western troops were bombing, arresting and torturing innocent Afghans. "He kept saying, 'It's our duty as Muslims to go there and help,' " said Ali.

That night, Ali recalled, Zubair turned to him and asked point-blank: "Do you want to join the jihad?"

The son of a truck driver, Ali said he had never belonged to any religious movement and had never attended any of the thousands of free religious schools that cater to impoverished Pakistani children. Instead he had dropped out of public school at 13 to take a series of odd jobs, most recently as a security guard.

During that pivotal evening in Miram Shah, Ali said he thought of his wife and 1-year-old son, who lived with his parents in a mud hut. But he also thought of how he had often seethed at the idea of U.S. troops in Muslim lands such as Afghanistan and Iraq and at the U.S. military's detention of Muslim prisoners at Guantanamo Bay, Cuba.

"It was like Zubair had poured the petrol, lit the match and set fire to this issue of jihad for me," he said.

Several days later, Ali said he boarded a public bus for the four-hour journey from Peshawar, the city nearest his village, to the northeastern Pakistani mountain town of Mansehra. He carried only a backpack stuffed with three changes of clothes and a bar of soap. His ears rang with his mother's wails of protest at the news that he was setting off for jihad.

But as the bus sputtered through the flat, hot plain of his youth into hilly green terrain, Ali said his only concern was whether he would prove physically fit for the regimen ahead. Otherwise, he said, he felt deeply happy.

"I knew then that when I was killed in jihad, I would go directly to heaven," he said, smiling.

On reaching the bus stop in Mansehra, Ali walked to a stand selling fried dumplings and looked for the contact Zubair had promised would be waiting.

"Salaam aleikum," peace be to you, he said tentatively to a middle-age man with a long beard.

"Are you the person who has come from Peshawar?" the man asked.

Ali nodded, and the man quickly led him to another bus, this one far more dilapidated. They rode for an hour to a small town, then alighted and began a steep hike up into the hills, following no discernable path. For more than four hours they trekked in silence under a cool canopy of trees, taller than any Ali had ever seen.

Finally they reached a small camp of five white tents, where about 20 men were preparing to perform afternoon prayers. Ali was introduced to a soft-spoken Pakistani instructor who never gave his name, though Ali said he overheard others refer to him as Maksud.

Maksud never gave the name of the group that was training him, Ali said. However, the hills around Mansehra overlook Pakistan's border with Kashmir, a disputed Himalayan province that is split between Pakistan and India.

The area has long been a training ground for Kashmiri guerrillas, unofficially supported by Pakistan. In recent years, several Kashmiri groups have joined forces with al Qaeda or the Taliban to attack Western targets, but critics charge that the Pakistani military remains reluctant to defang them.

Every day, Ali said, the trainees awoke before dawn and did sprinting exercises for 20 minutes. They spent several hours learning how to assemble, aim and fire weapons, from Kalashnikov rifles to rocket-propelled grenade launchers, although Ali said there was only one rocket, so the trainees never actually fired it.

Despite the loud bangs emanating from the camp, Ali said, Maksud took pains to conceal it and warned the trainees not to wander too far away.

Shortly after Ali returned to Peshawar, he said, Zubair arrived and announced they would drive into Afghanistan the next morning. Ali said Zubair never told him whom they would be joining, but an Afghan intelligence investigator said Ali had confessed under interrogation that Zubair was working for a senior Taliban commander, Jalaluddin Haqqani.

Ali said Afghan border guards waved them into Konar, assuming they were Afghan. But some miles later, police stopped their taxi. When they discovered Ali did not have identity papers, they arrested him.

Ali complained that the Konar police kept him tied up for several days and threatened to hurt him. But he said that he was never beaten and added he had been pleasantly surprised by the extent to which Afghans appeared to be in charge of their country.

Still, the Pakistani prisoner remained skeptical and defiant. The interview over, Ali rose from his chair in the investigator's office and began to shuffle out of the room. Suddenly, he stopped and popped his head back through the door.