In a country as repressive as Iran, it’s difficult to gauge where the current countrywide protests are leading. But a bold theory that predicted the recent transition to democracy in Tunisia may offer some clues.

In 2008, U.S. demographer Richard Cincotta predicted that Tunisia - then under a well-established authoritarian regime - would probably democratize before 2020 based on the age structure of its population. When Cincotta aired the forecast at a meeting of Middle East experts sponsored by the U.S. State Department, the audience burst into laughter.

“One well-known Middle East scholar laughed until he was in tears,” Cincotta recalled in a 2017 paper explaining his age-structural theory of state behavior. “Because the laughter did not subside, the session’s chair ended the question and answer session.”

Today, Tunisia is the one success story of the Arab Spring chain of revolutions that began there in 2010. It is classified as “Free” by Freedom House, whose rating system Cincotta uses in his analysis.

The reason Cincotta picked it out among regional neighbors - including those that would soon live through revolutions, too - was that thanks to a sustained near-replacement fertility rate, the Tunisian population’s median age was rapidly increasing, moving the country along Cincotta’s age-structural scale. The scale has four stages: youthful (median age under 25), intermediate (under 35), mature (under 45) and post-mature (higher than 45).

In “youthful” countries with high fertility rates, schools are usually crowded, investment per student is low and competition for jobs among young people is intense. That raises their propensity to protest and increases the chance of a revolution. According to Cincotta, the probability that a regime controlling a population with a median age of 15 is free from civil conflict is about 60 percent. It goes up to 80 percent at an average age of about 27, and civil conflict becomes almost unthinkable when half the population is older than 40.

While a country is in a youthful phase, however, an uprising is highly unlikely to result in sustainable democratization. Cincotta has shown that most such countries revert to authoritarianism; that may help explain why the Arab Spring didn’t end up democratizing Egypt (median age 24) but established a functional democracy in Tunisia (median age 32).

Today, Iranians are getting older. Thanks to successful fertility-control policies of the 1980s (now regretted by the country’s religious leadership), Iran is rapidly going through the intermediate age-structural phase, just as Tunisia did. This, according to Cincotta, is a window for economic growth and political change favoring the middle class.

Countries in this phase usually have just enough resources for a workable education system, and there are plenty of young workers and consumers - and few enough dependents, both young and old - to ensure increases in prosperity, as well as demand for democracy. In the 2017 paper, Cincotta published his model’s predictions of the probability of certain Middle Eastern countries’ being declared “Free” in the current year by Freedom House. Iran came out near the top.

The paper came out early last year, and Iran’s democratization looked so unlikely that Cincotta was forced to add a disclaimer: “Ideological political monopolies (e.g., Iran) characteristically behave without deference to the order of the list.” Now, after a week of protests and even riots that have combined economic and political demands, including liberalization and greater openness to the world, some lasting democratic change no longer looks out of the question.

It may not come through a violent revolution, though. In an article published by the Carnegie Endowment in December, but before the protests began, Cincotta and Karim Sadjadpour wrote:

“As Iran’s youth bulge dissipates and the country’s median age increases, the population will likely become increasingly averse to risky, violent confrontations with the regime. Consequently, political changes in Tehran could move more slowly than Washington might wish.”

Some of the current protests’ dynamics suggest that this prediction may turn out to be accurate. Young people under the age of 25 appear to be the driving force of the anti-government actions, and they definitely make up the bulk of the hundreds of activists detained by the authorities so far.

But the protesters are less numerous than in 2009, the previous time the Iranian regime faced serious domestic resistance, and the Tehran middle class hasn’t joined them, fearful of violence and chaos. And while the country’s leaders have threatened tough action, and, indeed, some 20 people have been killed in street fighting, President Hassan Rouhani has offered some conciliatory rhetoric. He acknowledged the people’s right to protest and the legitimacy of their economic gripes. That may mean concessions and a partial liberalization are likely. Just as the protests were starting, Tehran police announced that they would no longer arrest women for breaking the country’s strict Islamic dress code. Economic measures to pacify protesters unhappy about rising prices, corruption and inequality may well follow.

Iran’s religious leader, Ayatollah Ali Khamenei, has blamed Iran’s “enemies” for the unrest. But perhaps the country’s demographics have more to do with it than any foreign interference.

Though Cincotta’s theory has been dismissed as simplistic and criticized for not providing robust proof of causation, it’s intuitively convincing: A country with a young population has a relatively higher chance to change, and as it matures and more people have something to lose, this change is more likely to be peaceful and sustainable. The corrupt, highly unequal, repressive status quo is shaky in Iran because it doesn’t fit the country’s demographic window of opportunity.

Regardless of how change takes place in Iran, it’s worth noting the high probability of democratization that Cincotta’s method assigns to Turkey. President Recep Tayyip Erdogan’s regime looks rock-solid and bent on tightening screws. But Iran, too, looked immutable just weeks ago, and so did Tunisian President Zine El Abidine Ben Ali’s regime in 2008.

Leonid Bershidsky is a Bloomberg View columnist.