By Jeffrey Goldberg

So here’s a question that’s nagging at me as we watch millions of Egyptians express their loathing for Mohamed Morsi, their hapless, power-grabbing president, and for his Muslim Brotherhood movement: How exactly did the U.S. come to be seen by Egyptian secularists and liberals as the handmaiden of a cultish fundamentalist political party whose motto includes this heartening sentiment: “Jihad is our way, and dying in the way of Allah is our highest hope”?

I mean, how did the U.S. fail to formulate a strategy that would advance both American interests and American values in the largest and most crucial Arab state? Within a span of just a few years, Egyptians have somehow convinced themselves that the U.S. has been an ally of both Egypt’s former dictator, Hosni Mubarak, and Mubarak’s main enemy, the Muslim Brotherhood.

Now, Egypt is again on the brink of chaos, and the White House’s call for Morsi to schedule early elections won’t convince many Egyptians that President Barack Obama is on the side of the people.

Much of the ire in Tahrir Square, and at many other demonstrations across Egypt, has been directed at U.S. Ambassador Anne Patterson. Patterson is one of the State Department’s most skilled and respected diplomats, but a large number of Egyptians now view her as an enemy of progressivism and secularism.

The charges against Patterson and the Obama administration are simple: They have enabled Morsi by refusing to pressure him to bring other parties into his governing coalition, by soft pedaling his various power grabs, by ignoring the complaints of liberals and by cozying up to his patrons in the Muslim Brotherhood.

This being Egypt — where all conspiracy theories have their proponents — the complaints against Patterson can be outlandish. But an Egyptian blogger who goes by the name The Big Pharaoh says that Patterson’s actual record is bad enough. One reason for this week’s huge outpouring of anti-American invective was the meeting Patterson had last month with Khairat el-Shater, the deputy supreme guide of the Muslim Brotherhood. “She didn’t meet him in the embassy, she didn’t meet him in a restaurant, she went to his office,” the blogger told me. “This infuriated many people.”

Patterson and her superiors in the Obama administration argue that Morsi is Egypt’s elected president and that respect must be paid to the will of the voters. In a recent speech to Egyptians at the Ibn Khaldun Center for Development Studies, Patterson said: “This is the government that you and your fellow citizens elected. Even if you voted for others, I don’t think the elected nature of this government is seriously in doubt. Throughout Egypt’s post-revolution series of elections, the United States took the position that we would work with whoever won elections that met international standards, and this is what we have done.”

But Patterson’s critics aren’t upset that she talks to the government. They’re upset by what she says when she does talk. She has issued only the mildest condemnations of Morsi’s various attempts to seize absolute power, and she has been criticized for talking to opposition forces only intermittently. She clearly underestimated the size and ferocity of the anti-Morsi forces, and said in her speech that she was “deeply skeptical” that the protests would achieve their goal. I’m sure, though, that the sight of hundreds of thousands of Egyptians in the streets of Cairo condemning the president has educated her on the potency of the opposition.

The crisis of the past few days, which may end in a military coup (which would then start the next crisis), might have been avoided had the Obama administration used its leverage — the $1.5 billion in aid the U.S. is giving Egypt this year, for starters — to force Morsi to include the opposition in his government from the outset. It didn’t. And the Egyptian masses noticed.

Jeffrey Goldberg is a Bloomberg View columnist.