It would be a remarkable, surprising and happy irony if Egypt’s military, dictatorial rulers of their nation from 1952 to 2012 used their power to bring about truly democratic rule in that troubled country.

That is what the leader of Egypt’s armed forces seemed to promise Monday when he gave President Mohammed Morsi until today to settle the disagreements that have brought millions into the streets of Cairo and other cities to protest his rule.

“If the people’s demands are not met, the military, which is forced to act according to its role and duty, will have to disclose its own future plan,” said Gen. Abdel Fattah Al Sisi, Egypt’s defense minister and head of the Supreme Council of the Armed Forces, in a televised address. “These steps will include discussions between all political powers, specifically the youth, who were and continue to be the spark of the revolution. No one party will be excluded or marginalized.”

He appeared to allude to complaints by demonstrators that President Morsi, last year’s winner of Egypt’s first free election, has favored the Islamist policies of his Muslim Brotherhood over dialogue and accommodation with the more secular and religiously diverse opposition. Along the misguided way, Mr. Morsi has forced a seriously flawed constitution on the nation and exceeded his powers of office.

So far, President Morsi has refused to negotiate, saying the demands of the opposition are unconstitutional. But it is clear from last weekend’s massive demonstrations that he will be unable to govern unless he finds a way to settle his disagreements with the opposition. And while some analysts might call it a military coup, such a change in power could actually lead to a more democratic government in Egypt. In short, Mr. Morsi and the Muslim Brotherhood have tried to go too far, too fast to push Egypt, long a nation with a strong secular tradition, in the direction of a strict governing interpretation of the Koran. In doing so they have alarmed a wide range of Egyptians who fear a new form of dictatorship, this time with a strong religious foundation.

President Barack Obama, who finished his trip to Africa on Tuesday, has been criticized by Egyptian demonstrators for being willing to work with the Morsi government. But to Mr. Obama’s credit, he and his State Department have consistently urged the different sides in Egyptian politics to talk and seek common ground — something President Morsi has so far declined to do.

Indeed, President Obama warned the Egyptians, in a speech delivered in Cairo in 2009, that “there are some who advocate for democracy only when they are out of power; once in power, they are ruthless in suppressing the rights of others. No matter where it takes hold, government of the people and by the people sets a single standard for all who hold power: you must maintain your power through consent, not coercion; you must respect the rights of minorities, and participate with a spirit of tolerance and compromise; you must place the interests of your people and the legitimate workings of the political process above your party. Without these ingredients, elections alone do not make true democracy.”

There is little the U.S. can do directly to affect the outcome in Egypt. And Mr. Morsi has so far failed to take President Obama’s sound advice.

But if he doesn’t heed the Egyptian military’s warning, somebody else will likely get the opportunity to bring truly democratic rule to a nation that is clearly yearning for it.