Egyptian officers are also, in most cases, patriots who want to see their country become a prosperous, honestly run place. They knew very well that the old regime (whose remnants, like Tantawi, still controlled all the senior military posts) had failed dismally in that regard. Many were reluctant to let an Islamic party like Morsi's take full control of the country even though the voters chose it, but they now seem willing to take the chance.
Two months ago it looked like game, set and match to the Supreme Council of the Armed Forces (SCAF), led by Tantawi, which was essentially the old regime minus its former head, Mubarak.
Only 48 hours before the results of the presidential election were to be announced last June, the Supreme Constitutional Court (whose judges were all appointed by the old regime) issued a decree dissolving the Parliament elected eight months ago.
They said rules on the eligibility of candidates had been misinterpreted in some districts, but their real aim was to get rid of a Parliament in which the Islamic parties had won most of the seats.
Then, as the presidential votes were being counted and it was becoming clear that Morsi would win, SCAF issued decrees that gave it the sole right to call a new parliamentary election and to write the constitution under which it would be held. It also stripped the incoming president of any right to control the armed forces, and in particular to appoint or dismiss military officers in senior jobs.
Morsi refused to recognise the legality of these decrees, but he did not openly confront the military. He just waited for the military high command to make a really embarrassing mistake - which it duly did.
Islamist fanatics had taken advantage of Egypt's revolution, which distracted everybody's attention from keeping the militants under control, to create bases in the Sinai peninsula, near the country's border with Israel. On August 5, they attacked an Egyptian border post and slaughtered 16 guards.
In their own fevered imaginations, they were justly killing collaborators who were hindering true Muslims like themselves from making attacks on Israel. In the minds of most Egyptians, they had murdered 16 innocent young Egyptian men whose only crime was serving their country.
Morsi seized the opportunity to dismiss General Murad Mowafi, the head of military intelligence, for failing to forestall the atrocity.
Mowafi's post made him one of the most powerful men in the country, but nobody wanted to defend him after such an abject failure of intelligence. He went quietly - and by this action Morsi had successfully asserted his right to remove military commanders despite SCAF's June decree to the contrary.
The most important political skill is remembering your ultimate objectives, but biding your time until some passing event creates an opening for getting what you want. When the officer corps did not resist Mowafi's dismissal, Morsi knew he could win a head-on confrontation with Tantawi and his cronies. They knew it too, so they went quietly.
Egypt now has a democratically elected civilian government that exercises real control over domestic and foreign policy for the first time in its history.
What Morsi will do with that power remains to be seen, but he has certainly won the chance to use it.
Gwynne Dyer is a London-based independent journalist whose articles are published in 45 countries.