Two very different political waves are sweeping through the Middle East and north Africa. Popular protests are overthrowing the leaders of military regimes for the first time since the failed Arab Spring of 2011. At the same time, dictators are seeking to further monopolise power by killing, jailing or intimidating opponents who want personal and national liberty.

Dictators in Sudan and Algeria, who between them had held power for 50 years, were driven from office in the space of a single month in April, though the regimes they headed are still there. The ousting of Sudanese president Omar al-Bashir, now under arrest, came after 16 weeks of protests. Hundreds of thousands continue to demonstrate, chanting “civilian rule, civilian rule” and “we will remain in the street until power is handed over to civilian authority”.

The protesters are conscious of one of the “what not to do” lessons of 2011, when mass demonstrations in Egypt got rid of President Hosni Mubarak, only to see him replaced two years later by an even more authoritarian dictatorship led by General Abdel-Fattah el-Sisi. A referendum is to be held over three days from this Saturday on constitutional amendments that will enable el-Sisi to stay in power until 2030.

Given that he was re-elected president last year by 97 per cent of the vote – the remaining 3 per cent going to a last-minute candidate who did not campaign and enthusiastically supported el-Sisi – there is no doubt about the outcome of the poll.

Fortunately, even hypocritical respect for democratic forms can backfire, as shown by recent events in Algeria. In February, it was announced that President Abdelaziz Bouteflika, nominally in power for 20 years but apparently in a coma since 2014, would stand for a fifth term. This, like the Egyptian referendum, was an expression of contempt for any real popular mandate.

But the contempt went a little bit too far and Bouteflika has been replaced by another old regime figure, Abdelkader Bensalah, backed by, among others, the army chief of staff Ahmed Gaid Salah. Protesters reject these cosmetic changes and have continued to demonstrate in the face of mass arrests and beatings by the police.

The success of popular action and civil disobedience in Sudan and Algeria has been treated sceptically by commentators speaking in gloomy tones of a rerun of the 2011 protests, which began in Tunisia and sparked further protests in Egypt, Libya, Yemen, Syria and Bahrain. In these last five countries, a brief democratic spasm was followed by savage repression (Egypt and Bahrain) or permanent war (Libya, Yemen, Syria).

The pessimists might just be getting it wrong this time round, just as the optimists did eight years ago. The revolutionaries have learned from their past defeats. There are no chants in Khartoum today, as there were in Cairo in 2011, that “the army and the people are one”. More realise that armies in the Arab world are parasitic entities, bloated maggots that live off the flesh of the rest of the population.

The political, social and economic ingredients that went into igniting the Arab Spring are still there because repression and poverty have got worse. Thirty million Egyptians, a third of the population, live below the poverty line on less than $2.50 a day. The public debt is five times what it was five years ago, while the government favours giant vanity projects like a $45bn new administrative capital.

It is in the interests of the opposition in Sudan and Algeria to keep their protests peaceful whatever the provocation. Militarisation of a crisis like this is always in the interest of the powers-that-be because they know that, in the words of the Hilaire Belloc rhyme: “Whatever happens, we have got/ The Maxim gun and they have not.” Once regular soldiers get shot at, they are less likely to defect to the side doing the shooting.

Military action also means that an opposition will need money and weapons in large quantities. They can only obtain these from outside powers pursuing their own egocentric agendas which do not include genuine concern for ordinary Libyans, Syrians, Iraqis or Yemenis.

The discrediting or defeat of political Islam since 2011 is a bonus for revolutionary forces. Over the past 40 years, religion had become the vehicle for all sorts of grievances and resistance to oppression in the region, a shift dating from the Iranian revolution and the Soviet invasion of Afghanistan in 1979-80. Shia and Sunni Islamists largely displaced nationalists and socialists as the motivators of mass popular action.

Islamic ideology and organisation gave great punching power to opposition movements in Algeria in the 1990s, in Iraq after 2003, and to the anti-government forces in Libya, Egypt, Syria and Iraq after 2011. Fanatical religious belief united people who would die fighting against a more numerous and better-armed enemy.

But the prominence of jihadi Islam in these insurgencies was good news for established regimes. Al-Qaeda type groups like Isis might pose a dangerous but temporary military challenge, but they always alienated the large part of the population that were not Sunni Arabs or were only moderately religious. Dictators benefited because the alternative to their brutal rule seemed even more horrific. I remember being in Baghdad in 2004 when Shia office workers were giving blood for wounded Sunnis in Fallujah when it was first besieged by US troops. There was a second siege later in the year but, by this time Shia civilians had been killed and injured by deadly suicide bombs apparently emanating from Fallujah, so the former blood donors were all in favour of US airstrikes and artillery obliterating the town.

It was not just Shia in Iraq, Alawites in Syria and Copts in Egypt who were alienated by militant Sunni Islam. So too were those who might go to the mosque on Friday, but were otherwise broadly secular. People like this were shocked when, as happened in Libya after the overthrow of Muammar Gaddafi, they learned that one of the first acts of the provisional government was to propose ending the ban on polygamy.

A trap that opposition movements often fall into is to believe that all the problems of their country are caused by the evil rulers they are trying to displace. This will inevitably be part of opposition propaganda, but it is damaging to act as if this was true. Again and again in Iraq after 2003 and in Syria after 2011, the anti-government forces would compel religious and ethnic minorities to rally to the central government because they feared they faced extinction if they did not.

Sectarian exclusivity is less prevalent today and protesters know what damage it can do to their cause. A telling slogan of the Sudanese Professionals Association, which is leading the protests and wants to include non-Muslims, is “Christ at the heart of the Revolution”.

Some of the powerful forces determined to stop revolutionary change in the Arab world are the same in 2019 as they were in 2011. The Arab Spring was a curious mix of revolution and counter-revolution to a degree seldom appreciated in the west. It was extraordinary to see people fighting and dying for liberty and equality with the backing the last absolute monarchies on earth, Saudi Arabia, Qatar and UAE, who most certainly wanted neither of these things.

We have seen the same process at work in Libya over the past few weeks where Saudi Arabia, the UAE and Egypt have greenlit an offensive by Gen Khalifa Haftar, whose forces are firing mortar bombs and rockets into Tripoli. Haftar has already shown his determination to be another strongman in the Arab world by posing grim-faced for cameras on a sort of throne of pharaonic proportions. The revolutionaries may have learned some lessons from 2011, but the military dictators are as nasty and pretentious as ever.