The theological justification for al Qaeda's wholesale slaughter of civilians was provided by Sayyid Imam al-Sharif, also known as Dr. Fadl, one of the founding fathers of al Qaeda. Because the murder of innocents is forbidden in Islam and the murder of Muslims in particular, Ayman al-Zawahiri and Osama bin Laden required some sort of theological framework for justifying terrorism. This was provided by al-Sharif, who essentially argued in his book, "The Compendium of the Pursuit of Divine Knowledge," that apostates could be murdered, and that approach, takfir (which has come to be known as takfirism) allowed al Qaeda to, for all intents and purposes, kill anyone they wanted without violating the laws of Islam by declaring them to be apostates. In other words, Dr. Fadl helped provided a theological justification for something that everyone involved knew was wrong.
The legal memos justifying torture aren't very different in terms of reasoning--it's clear that John Yoo and his cohorts in the Office of Legal Counsel saw their job not as binding the president to the rule of law, but to declare legal any tactic that the executive branch believed necessary to fight terrorism. They worked backwards from this conclusion, and ethics officials at the Department of Justice, we now know, decided that they they had violated professional standards in doing so. Whereas al-Zawahiri and bin Laden turned to al-Sharif for a method to circumvent the plain language of the Koran, Bush and Cheney went to Yoo and Jay Bybee to circumvent the plain language of the law. Most Islamic scholars, just like most legal experts, reject their respective reasoning as unsound.
The torture memos--indeed, all of the pro-torture arguments rest on a similar intellectual themes to the takfiris. Suspected terrorists are "illegal enemy combatants", outside the framework of laws that would otherwise guide us. Just as the takfiris justify the killing of even self-identified Muslims by excommunicating them as "infidels", torture apologists argue that even American citizens like Jose Padilla who are accused of being terrorists become legal "apostates" without any rights the president is bound to respect. These are extraordinary circumstances, this is an extraordinary war--and so, the Bush administration turned to Yoo, a man who believes the president is bound by no laws during wartime: he can murder a village of innocent civilian non-combatants just as surely as he can crush the testicles of a child or deploy the military against residents of the United States. The architects of torture are the intellectual mirror image of their declared enemies, depending on the perceived inhumanity of their foes to justify monstrous actions. It's worth noting however, that the Bush administration did not take full advantage of the wrongs that the lawyers in their Office of Legal Counsel would have enabled. My point is not to equate the deeds of AQ with the deeds of the Bush administration--merely to point out justification for acts that are on their face unjustifiable take a similar intellectual path.
From his cell in an Egyptian prison, al-Sharif denounced his former colleagues in al Qaeda, declaring that the killing of innocents was wrong. He essentially renounced his earlier work providing the theological basis for politically motivated murder and destruction, declaring, "There is no such thing in Islam as ends justifying the means," now arguing that the murder of innocents, Muslim or otherwise, was sinful. Whatever theological cover al-Sharif's original arguments provided were meaningless against the body count of mostly Muslim innocents amassed by al-Qaeda in their war against the "West", which by the numbers has been a war against fellow Muslims. In combination with the furious efforts of moderate Muslims and even committed Islamists like al-Sharif, al Qaeda and its methods have been largely discredited, to the point where, as Fareed Zakaria writes, we don't fear "a broad political movement but a handful of fanatics scattered across the globe."