President Barack Obama has rightfully condemned the ISIS beheading of American James Foley in the strongest terms. This is what he said:

“There has to be a common effort to extract this cancer so it does not spread. There has to be a clear rejection of the kind of a nihilistic ideologies. One thing we can all agree on is group like (ISIS) has no place in the 21st century. Friends and allies around the world, we share a common security a set of values opposite of what we saw yesterday. We will continue to confront this hateful terrorism and replace it with a sense of hope and stability.”

At the same time that President Obama has called for an all-out war against the “cancer” of ISIS, he has regarded Hamas as having an easily curable disease, urging Israel to accept that terrorist group, whose charter calls for Israel’s destruction, as part of a Palestinian unity government. I cannot imagine him urging Iraq, or any other Arab country, to accept ISIS as part of a unity government.

Former President Jimmy Carter and Bishop Desmond Tutu have gone even further, urging the international community to recognize the legitimacy of Hamas as a political party and to grant it diplomatic recognition. It is hard to imagine them demanding that the same legitimate status be accorded ISIS.

Related coverage Entebbe: Are We Heeding the Lessons? July 4th marks the 40th anniversary of the rescue of Israeli hostages at Entebbe. Today we are surrounded by international terrorism....

Why then the double standard regarding ISIS and Hamas? Is it because Hamas is less brutal and violent than ISIS? It’s hard to make that case. Hamas has probably killed more civilians—through its suicide bombs, its murder of Palestinian Authority members, its rocket attacks and its terror tunnels—than ISIS has done. If not for Israel’s Iron Dome and the Israeli Defense Forces, Hamas would have killed even more innocent civilians. Indeed its charter calls for the killing of all Jews anywhere in the world, regardless of where they live or which “rock” they are hiding behind. If Hamas had its way, it would kill as least as many people as ISIS would.

Is it the manner by which ISIS kills? Beheading is of course a visibly grotesque means of killing, but dead is dead and murder is murder. And it matters little to the victim’s family whether the death was caused by beheading, by hanging or by a bullet in the back of a head. Indeed most of ISIS’s victims have been shot rather than beheaded, while Hamas terrorists have slaughtered innocent babies in their beds, teenagers on the way home from school, women shopping, Jews praying and students eating pizza.

Is it because ISIS murdered an American? Hamas has murdered numerous Americans and citizens of other countries. They too are indiscriminate in who they kill.

Is it because ISIS has specifically threatened to bring its terrorism to American shores, while Hamas focuses its terrorism in Israel? The Hamas Charter does not limit its murderous intentions to one country. Like ISIS it calls for a worldwide “caliphate,” brought about by violent Jihad.

Everything we rightly fear and despise from ISIS we should fear and despise from Hamas. Just as we would never grant legitimacy to ISIS, we should not grant legitimacy to Hamas—at the very least until it rescinds its charter and renounces violence. Unfortunately that is about as likely as America rescinding its constitution. Violence, anti-Semitism and anti-Americanism are the sine qua non of Hamas’ mission.

Just as ISIS must be defeated militarily and destroyed as a terrorist army, so too must Hamas be responded to militarily and its rockets and tunnels destroyed.

It is widely, and in my view mistakenly, argued by many academics and diplomats that there can never be a military solution to terrorism in general or to the demands of Hamas in particular. This conventional wisdom ignores the lessons of history. Chamberlain thought there could be a diplomatic solution to Hitler’s demands. Churchill disagreed. History proved Churchill correct. Nazi Fascists and Japanese militarists had to be defeated militarily before a diplomatic resolution could be achieved.

So too with ISIS and Hamas. They must first be defeated militarily and only then might they consider accepting reasonable diplomatic and political compromises. Another similarity between ISIS and Hamas is that if these terrorist groups were to lay down their arms, there might be peace, whereas if their enemies were to lay down their arms, there would be genocide.

A wonderful cartoon illustrates this: at one end of the table is Hamas demanding “death to all the Jews!” At the other end is Israel’s Prime Minister Netanyahu. In the middle sits the mediator, who turns to Netanyahu and asks: “Can’t you at least come half way?”

No democratic nation can accept its own destruction. We cannot compromise—come half way—with terrorists who demand the deaths of all who stand in the way of their demand for a Sunni caliphate, whether these terrorists call themselves ISIS or Hamas. Both are, in the words of President Obama, “cancers” that must be extracted before they spread. Both are equally malignant. Both must be defeated on the battlefield, in the court of public opinion and in the courts of law. There can be no compromise with bigotry, terrorism or the demand for a caliphate. Before Hamas or ISIS can be considered legitimate political partners, they must give up their violent quest for a worldwide Islamic caliphate.