As Hosni Mubarak teeters on the brink, a lot of wishful thinking is emanating from the West - both from those who want him gone and those who don't. But it does scant justice to the complexity of the situation to claim that Mr. Mubarak was a superb ally, or to imagine that we can manage an easy transition to a post-Mubarak regime.

The best that can be said for Mr. Mubarak is that he has been easy for the West to deal with. He is always ready to spur along Israeli-Palestinian negotiations and to stage military exercises with the United States. He is certainly a dedicated foe of Gamaa al Islamiya and other Islamist terrorist organizations that threatened his rule. Above all, he did not renounce the peace treaty with Israel that had gotten his predecessor, Anwar Sadat, killed. Behind the scenes, Mr. Mubarak and Omar Suleiman, formerly his intelligence chief and now his vice president, have had close relations with a succession of Israeli prime ministers and American presidents.

But let's not romanticize the soon-to-be-departed dictator. He presided over a very cold peace with Israel. Even as he was negotiating with Israeli leaders, he was turning a blind eye to the rabid anti-Semitism and anti-Westernism that polluted Egypt's state-controlled news media and mosques. The Middle East Media Research Institute has an invaluable archive of these revolting statements. Last year an Egyptian cleric, Hussam Fawzi Jabar, was quoted as saying, "Hitler was right to say what he said and to do what he did to the Jews." Keep in mind that in Egypt most clerics are state employees whose pronouncements are carefully monitored by the secret police. That Mr. Jabar is able to say such things in public means that Mr. Mubarak doesn't object.

Consider the two-part essay, "The Lie About the Burning of the Jews," that appeared in 2004 in Al Liwaa Al-Islami (The Islamic Banner), an official journal of Mr. Mubarak's National Democratic Party. The article is a statement of Holocaust denial, claiming that Hitler's genocide was invented by the Zionists to justify the creation of the Jewish state. At least the editor-in-chief of Al Liwaa Al-Islami was fired after that incident, under heavy American pressure.

By contrast, no one in Egyptian state television has been disciplined for its 41-part series "A Knight Without a Horse," which ran in 2002 and dramatized that old canard of anti-Semitism, "The Protocols of the Elders of Zion." That cinematic masterpiece was produced in cooperation with Hezbollah's Al-Manar television, which suggests that Mr. Mubarak is hardly an inveterate foe of all things Islamist.

Indeed he often did little to stop the massive smuggling of supplies into Hamas-controlled Gaza. His attitude has seemed to be that Hamas can arm itself against Israel as long as it doesn't cooperate with its Egyptian Islamist brethren against him.

Like other secular Middle Eastern dictators (e.g., the Assads in Syria or Saddam Hussein in Iraq), Mr. Mubarak played a canny double game with the Islamists, ruthlessly repressing their domestic attacks but turning a blind eye to their organizing and export of jihadism abroad.

Thus while Egypt's security services cracked down hard on Islamist terrorism in the 1990s when it was threatening the lucrative tourist trade, Mr. Mubarak has allowed the Muslim Brotherhood - the mother of all Islamist organizations - to become the main opposition party. This has made him, as he well knows, the indispensable man to the West - the only thing supposedly standing in the way of an Islamist power grab.

Yet Mr. Mubarak's police state actually drove many Egyptians into the arms of the radicals. It is no coincidence that al Qaeda started as primarily an Egyptian-Saudi organization run by citizens of two of our closest and most repressive allies. Ayman al-Zawahiri, al Qaeda's No. 2, was radicalized as a boy in Egypt and then all the more so after spending three years being tortured in Mr. Mubarak's dungeons in the 1980s.

Mr. Mubarak's downfall could well be a good thing in the long run if it opens up Egypt's closed political and economic systems to greater dynamism and debate, so that in the future frustrated young Egyptians can find peaceful expression rather than strapping on a suicide vest. Yet we should be realistic about the short-term costs of a new regime in a country that has been subjected to decades of anti-Western and anti-Israeli propaganda by Mr. Mubarak - and where many blame us (with some justification) for inflicting Mr. Mubarak on them. A government that better reflects the will of the people will be less willing to cut deals with the U.S. or Israel.

Mohammed ElBaradei, the former U.N. atomic agency head who has emerged as the leader of the opposition, made clear his anti-Israel sentiments in an interview last summer with the German magazine Der Spiegel. He called the Gaza Strip "the world's largest prison" and declared that it was imperative to "open the borders, end the blockade."

Mr. ElBaradei also spoke glowingly of Turkey's prime minister, Recep Tayyip Erdogan, who has assailed Israel in harsh terms and voted against United Nations sanctions on Iran. Mr. ElBaradei said: "Turkey is a member of NATO and partner of the West and Israel. And yet Prime Minister Erdogan has no qualms about supporting an aid flotilla for Gaza that was supposed to breach Israel's sea blockade. The people of the Arab world are celebrating him. Erdogan's photo can be seen everywhere."

That is probably what we can expect from a post-Mubarak Egypt. It is doubtful that Mr. ElBaradei would terminate Egypt's peace treaty with Israel - a move that would cost Egypt more than a billion dollars annually in American aid. But it is probable that, like Mr. Erdogan's Turkey, Mr. ElBaradei's Egypt would be less cooperative with Israel and more friendly to its enemies. In the Muslim world, this is actually a moderate position compared to the jihadism of the Islamists. But from the standpoint of the U.S. or Israel it is obviously far from ideal.

Yet what choice have we? Mr. Mubarak's day is done. It's only a question of time before he slinks out of office. The best the U.S. and our allies can do at this point is try to make the transition as fast and painless as possible.