David Petraeus is a retired U.S. Army general who commanded coalition forces in Iraq from 2007 to 2008 and Afghanistan from 2010 to 2011 and served as CIA director from 2011 to 2012.

Almost 15 years after the 9/11 attacks, and five years since the killing of the chief architect of those attacks, the United States and the world face a resurgent threat from terrorism. This stark reality should inform the national debate as we prepare to elect our next commander in chief.

As states across the Middle East have collapsed into civil war, Islamist extremist groups such as the Islamic State have exploited the upheaval to seize vast swaths of territory, which they have used to rally recruits, impose totalitarian rule over the people trapped in these areas and plot attacks against the rest of the world.

Few responsibilities that our next president inherits will be more urgent, important or complex than thwarting these terrorist plans, reversing the conditions that have enabled their rise and combating the broader Islamist extremist ideology that animates them.

It would be a mistake to minimize the continuing risk posed by these groups. Although al-Qaeda’s senior leadership ranks have been dramatically reduced, and while encouraging progress is being made against the Islamic State in Iraq and, to a lesser degree, Syria, these remain resilient and adaptive organizations. While Islamist extremist networks do not pose an “existential” threat to the United States in the way that Soviet nuclear weapons once did, their bloodlust and their ambition to inflict genocidal violence make them uniquely malevolent actors on the world stage.

Nor can they be “contained.” On the contrary, from Afghanistan before 9/11 to Syria and Libya today, history shows that, once these groups are allowed to establish a haven, they will inevitably use it to project instability and violence.

Moreover, the fact is that free and open societies such as ours depend on a sense of basic security to function. If terrorism succeeds in puncturing that, it can threaten the very fabric of our democracy — which is, indeed, a central element of the terrorist strategy.

For that reason, I have grown increasingly concerned about inflammatory political discourse that has become far too common both at home and abroad against Muslims and Islam, including proposals from various quarters for blanket discrimination against people on the basis of their religion.

Some justify these measures as necessary to keep us safe — dismissing any criticism as “political correctness.” Others play down such divisive rhetoric as the excesses of political campaigns here and in Europe, which will fade away after the elections are over.

I fear that neither is true; in fact, the ramifications of such rhetoric could be very harmful — and lasting.

As policy, these concepts are totally counterproductive: Rather than making our country safer, they will compound the already grave terrorist danger to our citizens. As ideas, they are toxic and, indeed, non-biodegradable — a kind of poison that, once released into our body politic, is not easily expunged.

Setting aside moral considerations, those who flirt with hate speech against Muslims should realize they are playing directly into the hands of al-Qaeda and the Islamic State. The terrorists’ explicit hope has been to try to provoke a clash of civilizations — telling Muslims that the United States is at war with them and their religion. When Western politicians propose blanket discrimination against Islam, they bolster the terrorists’ propaganda.

Minneapolis is home to one of the biggest populations of Muslim Somali's in the U.S. Some worry recent Islamist attacks overseas are creating an anti-Muslim backlash here at home. (Reuters)

At the same time, such statements directly undermine our ability to defeat Islamist extremists by alienating and undermining the allies whose help we most need to win this fight: namely, Muslims.

During the surge in Iraq, we were able to roll back the tide of al-Qaeda and associated insurgents because we succeeded in mobilizing Iraqis — especially Sunni Arabs — to join us in fighting against the largely Sunni extremist networks in their midst. Later, we took on the Iranian-backed Shiite militia, with the important support of the Shiite-majority Iraqi security forces.

Likewise, the rapid ouster of the Taliban regime after 9/11 was made possible by our partnership with Muslim fighters of the Afghan Northern Alliance. And in Southeast Asia, it was by working with the government of Indonesia — the most populous Muslim-majority country in the world — that Jemaah Islamiah, once one of al-Qaeda’s most capable affiliates, was routed.

The good news is that today, hundreds of thousands of Muslims are fighting to defeat the terrorists who wish to kill us all. This includes brave Afghan soldiers fighting the Islamic State and the Taliban, as well as Persian Gulf forces in Yemen battling both Iranian-backed Houthis and al-Qaeda in the Arabian Peninsula. And it includes Arab and Kurdish forces who are battling the Islamic State in Iraq and Syria. In fact, we should do more to support these partners of ours.

Inescapably, clearing territory of entrenched terrorist networks and then holding it takes boots on the ground. The question is — whether in Yemen, Libya, Somalia, Afghanistan, Iraq, Syria, Nigeria or Mali — do the bulk of those boots need to be our own or those of local Muslim partners?

I fear that those who demonize and denigrate Islam make it more likely that it will be our own men and women who ultimately have to shoulder more of this fight — at greater cost in dollars and lives.

We should also acknowledge that patriotic Muslim Americans in our intelligence agencies and armed forces — many of them immigrants or children of immigrants — have been vital assets in this fight with radical Islam.

It has also been through building ties of trust and cooperation between law enforcement and Muslim communities in the United States that we form our most effective defense against homegrown radicalization and lone-wolf attacks.

Again, none of this is to deny or diminish the reality that we are at war with Islamist extremism — a fanatical ideology based on a twisted interpretation of Islam. Nor is it to minimize the need for smart, intelligence-driven measures to prevent terrorists from infiltrating our borders and exploiting our immigration policies.

But it is precisely because the danger of Islamist extremism is so great that politicians here and abroad who toy with anti-Muslim bigotry must consider the effects of their rhetoric. Demonizing a religious faith and its adherents not only runs contrary to our most cherished and fundamental values as a country; it is also corrosive to our vital national security interests and, ultimately, to the United States’ success in this war.