In the wake of Benjamin Netanyahu’s victory in Israel, American leaders—both conservatives and liberals—should rethink their approach to the Middle East. Conservatives need to recognize more clearly who our enemies are; liberals need to learn to recognize our friends.

Over the last six years, conservatives have made two errors regarding the Middle East. First, they’ve emphasized the importance of the Iranian nuclear program. But the problem is not really the program; the problem is the nature of the Iranian regime that controls the program.

If Iran were a peaceful, democratic state in a placid neighborhood, its nuclear program would not be problematic. But Iran is none of those things: It is a thuggish theocracy that is feared by its neighbors.

By focusing on Iran’s nuclear program, conservatives have made it easy for President Obama to argue that, if a negotiated agreement can be reached, the problem of Iran would be solved. Not true. Not only does Iran not want to give up its program, it would still be violently destabilizing even without nukes.

The second error conservatives have made is to place too much emphasis on the dangers of the Islamic State group. Now, make no mistake: The Islamic State is evil. It does pose risks. But ultimately, states exist to exert power, and though the Islamic State pretends to be a state, it is a long way from being one.

Iran is a state. It can build a nuclear weapon. It has an intercontinental ballistic missile program. The Islamic State group can cut off heads, but Iran could soon have the ability to decapitate entire nations. When President George W. Bush said the greatest danger we face as a nation is a nuclear weapon in the hands of fanatics, he was right.

Today, the Islamic State does not pose that danger. Iran does. And the fact that the group is trying to control territory is a big advantage for us. When Islamist fanatics from around the world gather in big groups in the desert, it makes them better targets.

From Afghanistan to Egypt, Islamist regimes have proved to be far more popular in theory than they are in practice. That doesn’t always make them vulnerable to rebellions: They have too many guns for that. But the Islamic State is teaching people to hate Islamism, and that’s a good thing.

The liberal errors are the mirror image of the conservative ones—but far more important, because there is a liberal in the White House. The first liberal error is simple: Obama has shown more hostility to Netanyahu, the elected leader of a friendly democracy, than he has to the Iranian regime.

Compare Obama’s ungracious treatment of Netanyahu to his friendly Nowruz (the Persian New Year) message to “the people and the leaders of Iran,” in which he condemns “people . . . who oppose a diplomatic resolution.” No points for guessing who those “people” are.

That error leads to the second: Obama’s effort to engineer a détente with Iran. His outreach began as soon as he entered the Oval Office in 2009, and it hasn’t stopped since. We’ve now reached the point where Secretary of State John Kerry says we need to negotiate with Syria’s Bashar Assad, Iran’s murderous lackey.

By talking up the Islamic State’s evils, conservatives have justified Obama’s desire to cooperate with Iran. Today, we are not aligning with Iran to fight the Islamic State; we are fighting the Islamic State as a way to justify detente with Iran.

But it is fear of Shia Iran that drives Sunni Islamic State. We are feeding the problem, and we are aligning with the greater danger in Iran to do it. And that is Obama’s biggest error of all.

Originally published in Newsday