The Egyptian government recently passed a new law against spreading “rumors.” By “rumors,” the regime of Egypt’s President Abdel Fattah El-Sisi means anything that might undermine confidence in or tell the truth about his government. El-Sisi runs a military dictatorship, albeit one probably supported by most Egyptians. That puts journalists who report factually about events in the country or anyone with a Facebook account in potential peril; such offenders have swelled the already high population of dissidents in Cairo’s jails.

U.S. President Donald Trump greets the President of Egypt, Abdel Fattah El-Sisi, prior to their bilateral meeting on May 21, 2017, at the Ritz-Carlton Hotel in Riyadh, Saudi Arabia. Credit: Official White House Photo by Shealah Craighead.

Egypt’s record on human rights has gone from bad to worse as the regime led by the former general tightens its grip on power. However, in a development that set off a predictable chorus of opposition from the Trump administration’s critics, the U.S. State Department has lifted restrictions on $195 million in military aid to Egypt that were put in place a year ago in order to register American dismay about Cairo’s human-rights record, as well as its ties with North Korea.

The decision is being denounced as yet another indication that U.S. President Donald Trump cares nothing for human rights and likes dictators. But American policy toward Egypt isn’t a function of the president’s soft spot for strong men. To the contrary, the decision to double down on American backing for El-Sisi is a reflection of sober analysis, not a presidential whim. Moreover, it shows that Trump and Secretary of State Mike Pompeo are aware of the mistakes that President Barack Obama made about Egypt and why they shouldn’t be repeated.

The same things that can be said today about the El-Sisi regime can and were said about the government led by Hosni Mubarak, who led Egypt from 1981 to 2011. He succeeded to Egypt’s presidency after the assassination of Anwar Sadat, who was murdered by Islamic radicals for the sin of having made peace with Israel. Mubarak was determined not to suffer the same fate, managing to avoid it by a clever combination of brutal repression and maintaining an ice-cold peace with Israel.

Successive U.S. administrations were always queasy about the authoritarian nature of Mubarak’s regime. Yet they all kept billions in U.S. aid flowing to Cairo since that money was the price America paid to keep a dubious ally in power who maintained the status quo.

But once the Arab Spring protests began spreading across the region in December 2010, Obama believed it was the moment for the United States to embrace change. Much like the way many conservatives embraced the notion of spreading democracy in the Middle East during the administration of President George W. Bush, Obama thought supporting democracy was consistent with American values and in the nation’s strategic interests.

But Obama’s attempt to express American ideals in this manner was as much of a disaster as Bush’s had been. When demonstrations against Mubarak began, Obama pushed America’s ally out. While that seemed like the right thing to do, Obama was either oblivious or mistaken with respect to the question of who or what would succeed Mubarak when the United States made it clear to the Egyptian military that they must allow immediate elections.

The problem was that there was only one entity in Egypt that had the organizational strength to mount a successful national campaign: the Muslim Brotherhood.

While Obama and a credulous Western press fell for the Brotherhood’s efforts to depict itself as a band of Islamic democrats, their goals were very different from the ideals Obama spoke about. The Brotherhood was an Islamist group that was ready to fill the vacuum left by Mubarak’s collapse—and that’s exactly what they did. They swept to power in elections in 2012 that put their leader, Mohamed Morsi, in Mubarak’s chair.

Over the course of the following year, most Egyptians watched in horror as the Brotherhood sought to transform their country into a Sunni version of the Islamist theocracy created by Shi’ite clerics in Iran. Morsi ignored American efforts aimed at supporting democracy. When protests against the Brotherhood started spreading, Obama warned the Egyptian military not to try to overthrow Morsi. But as tens of millions of Egyptians took to the streets to oppose their nation’s drift towards extremism, the army, led by El-Sisi, ignored Washington and deposed Morsi.

The United States wound up being still being hated by Islamists for all the reasons they’ve always hated American democracy, while also angering Egyptians who blamed Obama for their year under the thumb of the Brotherhood’s tyranny. Though he did so reluctantly, even Obama had to admit that his policies had failed, and he grudgingly restored most of the aid he sought to withhold to punish the army for the coup.

While the United States wasn’t wrong to wish to aid the spread of democracy in the Arab world, Obama had learned that there were only two choices available in Egypt or anywhere else in the Arab world: a tyrannical military that would violate human rights but not seek to destabilize the region; or Islamists who would be just as, if not more, tyrannical as the army, but would also constitute a threat to both U.S. interests and Israel. The only rational thing for America to do was to join Israel in backing El-Sisi and the army.

For all of the horror it has inflicted on opponents, El-Sisi’s government has allied itself with Israel against Islamist radicals, including the Hamas government in Gaza (Hamas was born as an offshoot of the Muslim Brotherhood) and an Iranian regime that seeks regional hegemony.

It’s easy to criticize Trump for supporting a violator of human rights in Egypt. But we already know what happens when a U.S. president tries the alternative, and repeating that disaster is unthinkable. The El-Sisi regime is as brutal, corrupt and incompetent as that of Mubarak. That makes it an unreliable ally. But it’s better to have a weak and unsavory ally running the most populous Arab country than a strong and ruthless Islamist enemy. Say what you will about Trump’s foreign-policy acumen, but even he knows better than to repeat Obama’s Egyptian blunder.

Jonathan S. Tobin is editor in chief of JNS — Jewish News Syndicate. Follow him on Twitter at: @jonathans_tobin.