Amman, Jordan (CNN) -- In the murky world of spying, where choices are generally among shades of gray, success, by definition, goes unnoticed.
Failure, however, is catastrophic.
So how did a Jordanian doctor play double agent, outsmart his CIA handlers, and end up killing seven Americans and a Jordanian military officer at a remote base in Afghanistan?
"This is the biggest deception ever of intelligence agencies, whether CIA or Jordanian intelligence," said Hassan Hanieh, a former Islamic extremist who now studies jihadist movements. "From the beginning, he was deceiving them."
In a videotape released after the December 30 attack, the double agent, Humam Khalil Abu-Mulal al-Balawi, said his suicide bombing was retaliation for the death of Pakistani Taliban leader Baitullah Mehsud. Mehsud was killed in a missile strike in August, an attack thought to have been carried out by an American drone aircraft.
Al-Balawi had been recruited as a counterterrorism intelligence source, with U.S. and Jordanian intelligence agencies apparently believing he had given up his Islamic extremist views. They were using him to hunt Ayman al-Zawahiri, deputy to al Qaeda founder Osama bin Laden, a former U.S. intelligence official told CNN last week.
Hanieh told CNN he has read the bomber's radical blogs and says intelligence agencies made an obvious mistake in believing al-Balawi had changed.
"We have never seen in the history of al Qaeda a person who changed his ideas completely in this sudden way -- a person who writes jihadi stuff, then suddenly switches sides," Hanieh said.
And Ali Shukri, a former adviser to Jordan's late King Hussein, said the suddenness of al-Balawi's apparent reversal should have sent up red flags among the spies. Al-Balawi was in Pakistan only a few months before he began feeding his handlers high-grade tips.
"This is always a red flag," said Shukri, a veteran of Middle East espionage. "For someone who has been doing this to be turned is not an easy thing to do."
Sources familiar with intelligence operations in Jordan say al Qaeda takes at least a year to screen new recruits. The terrorist organization checks out their family backgrounds, gets input from fellow jihadists who know them -- and never trusts anyone who has been arrested, as al-Balawi had been.
A Jordanian official, speaking on condition of anonymity, said last week that authorities in Jordan arrested al-Balawi more than a year ago, but released him because of a lack of evidence. Al-Balawi had written about his arrest on his blog, and ignoring that was another fatal error by the intelligence agencies, sources said.
Shukri said al-Balawi's handlers should have asked whether he was "really on the inside, that much on the inside? Or was it a counterintelligence operation?"
Al-Balawi's family has said he was under pressure by Jordanian intelligence to infiltrate al Qaeda, making him potentially unreliable. Shukri said al-Balawi's handlers might have dropped their defenses, tempted by the prospect of striking a major blow against al Qaeda.
"Sometimes rules are broken," he said. "When you put something on a fast track, you tend to break rules. Maybe this is what happened here."
If true, that would violate another of the basic lessons of spycraft: Patience and caution are everything.