THE LATEST POLITICAL turmoil in Egypt has had at least one good result: Egyptians have shown — again — that they will strongly resist any return to autocracy. President Mohamed Morsi and his Muslim Brotherhood movement should learn that lesson from the massive popular backlash against Mr. Morsi’s attempt to assign himself sweeping powers and push through a new constitution. Though a referendum on the new charter was scheduled to go ahead Saturday, the president has been forced to retract most of his decree and to promise constitutional amendments. It seems likely that crisis-weary voters will approve the document, but the Islamist ruling party has suffered a blow that could weaken it in the new parliamentary elections expected early next year.

Egypt’s secular and liberal politicians should have learned a lesson about democracy as well. The masses who took to the streets and besieged the presidential palace called for another revolution — but their target was not a military-backed dictator such as Hosni Mubarak but a civilian president who had won a free and fair election. Too often, secular activists have appeared less interested in ensuring that Egypt creates democratic institutions than in preventing Islamists from taking over the government, elected or not. Fortunately, leaders of the opposition National Salvation Front eventually endorsed a no vote in the constitutional referendum rather than a boycott. That should be the beginning of a strategy that focuses on democratic organization and participation rather than street confrontations.

As it is, Egypt’s fraying social fabric has been further damaged. In Cairo, at least, the country looks badly polarized between the Islamist and secular camps, neither of which fully accepts playing by the rule of law or seeking reasonable compromises. Mr. Morsi’s government accuses its opposition of counter-revolution while attempting to intimidate the media, courts and any other institution outside its control. The opposition wildly compares the Islamists to the Nazi movement in 1930s Germany and hints that a military coup would be welcome.

The only solution is less confrontation and more democracy. The proposed constitution, while falling well short of liberal democratic standards, is somewhat better than the previous one; for example, it contains protections against arbitrary arrest and enshrines liberal rules for forming political parties and media. The military is granted too much power, and vague and contradictory provisions could be used by an Islamist government to restrict personal freedoms. But that only makes it more important that secular and liberal politicians — who collectively captured a majority in this year’s first-round presidential vote — make a concerted effort to unify, organize and appeal to voters in future elections.

Though it continues to fund the military and partnered with Mr. Morsi’s government during the recent Gaza crisis, the United States has been a bystander in the latest drama. To some extent, that is inevitable: Neither side in Egypt is particularly inclined to listen to Washington. But it is a vital U.S. interest that Egyptian politics remain pluralist, competitive and peaceful; the Obama administration must condition all aid on those priorities.