KABUL, Afghanistan  Abdul Khaliq Farahi’s kidnappers attacked fast, smashing into his car to stall it, seizing him and executing his driver as he tried to make a phone call. Within seconds, they were driving away to a hide-out just 20 minutes away.

It was Sept. 23, 2008, and Mr. Farahi, the Afghan consul general in the Pakistani border town of Peshawar, was driving home from work. His kidnapping was one of a series singling out foreign officials that included the taking of an Iranian diplomat and an attempt to kidnap the American consul, Lynne Tracey, who escaped thanks to the quick reactions of her driver.

Mr. Farahi, 52, spent two years and two months as a captive of Arab members of Al Qaeda in Pakistan’s lawless tribal areas. Questioned under torture for the first six months, he was moved 17 times. Apart from the first days when local Pakistani and Afghan militants handled him, he was always held by Arabs, he said.

He spoke for the first time at length about his two-year ordeal in an interview in a hotel in downtown Kabul, just yards from the presidential palace where he has been living as a guest of President Hamid Karzai since his release last November. Within days of being snatched, Mr. Farahi was driven deep into the mountains of South Waziristan, one of the most inaccessible of Pakistan’s tribal territories, where Islamist militants run a virtual ministate beyond the control of the Pakistani government.