EGYPT’S MILITARY coup has caused some to rush to the conclusion that the tide has turned against Islamist movements in the Middle East. That strikes us as a premature judgment. In Egypt and throughout the Arab world, Islamism surely will be a powerful political force for decades to come. The question is whether its followers will operate — and be allowed to operate — within the bounds of a peaceful democracy.

In that sense, the ouster of the Muslim Brotherhood government in Egypt has been a major and dangerous reverse. It is a setback for which President Mohamad Morsi and his government were partly responsible: Having won an election with 51 percent of the vote, Mr. Morsi and the Muslim Brotherhood movement broke promises to seek consensus with secular opponents and crudely sought to gain control over the media, the judiciary and nongovernmental organizations.

However, the unjustified military intervention that removed the Morsi government from office — and that has included the arrest of Islamist leaders, the shutdown of media and the reported shooting of unarmed demonstrators in Cairo Friday — has risked far greater damage. If the repression continues, what has been Egypt’s best organized and most disciplined political movement could be forced underground. Some Islamists could return to waging war against the state, as occurred in Egypt in the 1990s. Islamic parties around the region could abandon democratic politics.

That’s why it is essential that Egypt’s armed forces immediately end their arrests of Islamist leaders and open negotiations with them and secular politicians on a political settlement. Mr. Morsi’s followers are demanding that he be reinstated in office, under the constitution the military suspended. While the coup leaders are unlikely to accept that, they must offer the Muslim Brotherhood terms that will allow them to remain inside the political system. That means a commitment to new elections within months if not weeks, and freedom for the movement’s political party and media. Any changes to the constitution, which was ratified by two-thirds of voters in a referendum last December, should be the result of a consensus among political forces and a new referendum.

Most important, the armed forces must be willing to guarantee that the results of future elections will be accepted even if they lead to another Islamist victory. Some Egyptians appear to have convinced themselves that the Muslim Brotherhood no longer has popular support, but it, as well as more radical Islamist groups, has repeatedly surprised the Cairo elite with an ability to turn out voters. In other nations where military coups have removed elected governments, including Turkey and Thailand, parties linked to the former government have won subsequent elections.

Egypt’s neighbors and the United States have a vital interest in seeing Egypt’s crisis end with a political compromise. The Obama administration has been virtually silent since Wednesday’s coup, which it has declined to condemn; officials are said to be busy making calls to Cairo. Both in public and in private the United States should be demanding an end to the military’s repression and quick steps toward compromise with the Islamists. Meanwhile, the administration should comply with U.S. law requiring a cutoff of aid following military coups.