Mohammed Morsi would probably still be the president of Egypt if he had governed in an inclusive and effective way. It’s possible to recognize that fact and still lament the willingness of the Egyptian military to undo the results of a free and fair election that occurred only a year ago.

Morsi, the preferred candidate of the Muslim Brotherhood, was an inept leader who overreached his mandate and presided over a deterioration in the Egyptian economy. He antagonized not only the military — which sees itself as the guarantor of national stability — but also liberal, Christian and secular-minded Egyptians. Two years after crowds massed in cities across the country to demand the ouster of longtime strongman Hosni Mubarak, equally vociferous demonstrators turned out to demand that Morsi step down.

But there was a difference. Mubarak was a self-perpetuating tyrant. Morsi came to office as the result of a legitimate vote of his people. His replacement by an acting president chosen by the armed forces — even if it is followed fairly swiftly by new presidential and parliamentary elections — is a defeat for democracy and constitutional government.

In recent days the Obama administration has distanced itself from Morsi. On Monday, President Obama said that the U.S. commitment to Egypt “has never been around any particular individual or party” — an unobjectionable statement in the abstract but likely to be seen in Egypt as a signal that the United States wouldn’t protest too vehemently if Morsi were overthrown. We hope that wasn’t the president’s intention.

Given the strategic importance of Egypt, the United States must deal with whoever is in charge of that country. But it shouldn’t pretend that what has just happened in Egypt is anything but a setback for democracy.