The US “surge” in Iraq has been so manifestly successful that no serious person can deny that gains have been made. Even Hillary Clinton and Barack Obama have (grudgingly) conceded progress. Yet both Mrs. Clinton and Mr. Obama are quick to add that progress has been purely on the military side and that those gains are ephemeral. This fits with their broader narrative — that the war has been a disaster on every front.

During a recent Democratic debate, for example, Mr. Obama declared: “We are seeing al-Qaeda stronger now than at any time since 2001.” Mrs. Clinton says President George W. Bush’s policies in Iraq have “emboldened our enemies”. We should leave Iraq, she says, so we can better focus on the threat of al-Qaeda.

In fact, in large measure because of what is unfolding in Iraq, the tide within the Islamic world is beginning to run strongly against al-Qaeda — and this, in turn, may be the single most important ideological development in recent years.

In November 2007 Sayyid Imam al-Sharif (“Dr Fadl”) published his book, Rationalizations on Jihad in Egypt and the World, in serialised form. Mr. Sharif, who is Egyptian, argues that the use of violence to overthrow Islamic governments is religiously unlawful and practically harmful. He also recommends the formation of a special Islamic court to try Osama bin Laden and Ayman al-Zawahiri, al-Qaeda’s number two and its ideological leader, and calls the attacks on September 11 2001 a “catastrophe for all Muslims”.

Mr. Sharif’s words are significant because he was once a mentor to Mr. Zawahiri. Mr. Sharif, who wrote the book in a Cairo prison, is “a living legend within the global jihadist movement”, according to Jarret Brachman, a terrorism expert.

Another important event occurred in October 2007, when Sheikh Abd Al-‘Aziz bin Abdallah Aal Al-Sheikh, the highest religious authority in Saudi Arabia, issued a fatwa prohibiting Saudi youth from engaging in jihad abroad. It states: “I urge my brothers the ulama [the top class of Muslim clergy] to clarify the truth to the public . . . to warn [youth] of the consequences of being drawn to arbitrary opinions and [religious] zeal that is not based on religious knowledge.” The target of the fatwa is obvious: Mr. bin Laden.

A month earlier Sheikh Salman al-Awdah, an influential Saudi cleric whom Mr. bin Laden once lionised, wrote an “open letter” condemning Mr. bin Laden. “Brother Osama, how much blood has been spilt? How many innocents among children, elderly, the weak, and women have been killed and made homeless in the name of al-Qaeda?” Sheikh Awdah wrote. “The ruin of an entire people, as is happening in Afghanistan and Iraq … cannot make Muslims happy.”

These criticisms by prominent voices within the jihadist movement should be seen in the context of an even more significant development: the “Anbar Awakening” now spreading throughout Iraq. Just 18 months ago Anbar province was the stronghold of al-Qaeda in Iraq; today it is known as the birthplace of an Iraqi and Islamic grass-roots uprising against al-Qaeda as an organisation and bin Ladenism as an ideology. It is an extraordinary transformation: Iraqis en masse siding with America, the “infidel” and a western “occupying power”, to defeat Islamic militants.

Not surprisingly, al-Qaeda’s stock is falling in much of the Arab and Islamic world. A recent survey found that in January less than a quarter of Pakistanis approved of Mr. bin Laden, compared with 46 per cent last August, while backing for al-Qaeda fell from 33 per cent to 18 per cent.

According to a July 2007 report from the Pew Global Attitudes Project, “large and growing numbers of Muslims in the Middle East and elsewhere [are] rejecting Islamic extremism”. The percentage of Muslims saying suicide bombing is justified in the defence of Islam has declined in seven of the eight Arab countries where trend data are available. In Lebanon, for example, 34 per cent of Muslims say such suicide bombings are often or sometimes justified; in 2002, 74 per cent expressed this view. We are also seeing large drops in support for Mr. bin Laden. These have occurred since the Iraq war began.

Since General David Petraeus put in place his counter-insurgency strategy early last year, al-Qaeda has been dealt punishing military blows. Iraqis continue to turn against al-Qaeda and so does more of the Arab and Muslim world. In the past half-year an important new front, led by prominent Islamic clerics, has been opened. Militarily, ideologically and in terms of popular support, these are bad days for Mr. bin Laden and his jihadist jackals.

If we continue to build on these developments, the Iraq war, once thought to be a colossal failure, could turn out be a positive and even a pivotal event in our struggle against militant Islam. Having paid a high cost in blood and treasure and having embraced the wrong strategy for far too long, we stayed in the fight, proving that America was not the “weak horse” Mr. bin Laden believed it to be. Having stayed in the fight, we may prevail in it. The best way to subvert the appeal of bin Ladenism is to defeat those who take up the sword in its name.

We are a long way from winning in Iraq. It remains a traumatised nation and the progress made can be lost. But the trajectory of events is at last in our favour and a good outcome is within our grasp. If we succeed it will have enormously positive effects beyond Iraq.

— The writer, formerly deputy assistant to President George W. Bush, is a senior fellow at the Ethics and Public Policy Center