When I served as Mexico’s ambassador to China, I was often asked the wrong question: Is Mexico the next China? The better question is whether China is becoming the next Mexico.

Of course, it is hard to compare anywhere else to China given the sheer scale of the People’s Republic and its transformation. And yet, much like Mexico in the 1990s, China has long been ruled by a one-party dictatorship that has outgrown its ideological purity (all lip service aside) in favor of a widely acclaimed technocratic pragmatism. If there is a social contract in China, it boils down to the government telling its people: You all pretend to be communists, and so will we; but we’ll actually allow you to become wealthier by not being real communists, so long as you don’t rock the boat and play along.

It’s all very reminiscent of Mexico’s seven-decade rule by the Institutional Revolutionary Party (PRI). Nobel laureate Mario Vargas Llosa called the PRI’s run “the perfect dictatorship” because of the regime’s institutionalized nature, which transcended any one individual leader and its original revolutionary ideology, and ensured a peaceful succession of a new president every six years, or “sexenio.”

And like China in recent years, Mexico in the early 1990s was widely praised for having a highly capable team of technocrats running its economic policymaking and promising growth, stability, and a rising standard of living.

Mexico’s ruling technocracy was much admired outside the country. Many of the gushing news articles about Mexico written in the early 1990s, around the time of the North American Free Trade Agreement, sound very much like those written about China in the past decade. Forbes gushed, in typical fashion: “You can’t any longer think of Mexico as the Third World.” (In the 1960s, there had been a similar bubble in commentary about Mexico, at a time when the country did post China-like growth rates.)

Lost in all the rosy pronouncements about Mexico’s economy was any serious analysis of how people’s rising living standards and expectations would affect their nation’s political evolution. Indeed, there was very little acknowledgment that there may be a political and democratic evolution—as opposed to a merely economic one.

The same void exists now with China—even though the trend lines are remarkably similar to what Mexico went through leading up to its transformation in 2000 to a multiparty democracy. Ever since Mikhail Gorbachev launched his ill-fated glasnost policy for greater transparency and openness in the late 1980s, the Chinese Communist Party has been obsessively studying the fall of the USSR in order to escape the same fate. At his first meeting as president at Beidaihe, Xi Jinping made a point of referring to the errors of the Soviet Communist Party, and those of Gorbachev in particular, as examples to avoid.

President Xi might do well to study the Mexican case instead, given that today’s Chinese Communist Party has much more in common with the PRI than it did with the Soviet Communist Party. Where the Chinese Communist Party has its Three Represents, the PRI extolled its three sectores: labor, business chambers, and peasants. In both cases, the governments strived to maintain control, order, and stability on behalf of drama-wary societies that had experienced too much tumult throughout history.

In the six years I lived in China, I would very often have a feeling of déjà-vu: Life in China was exhilarating, mind-boggling, frustrating at times. But amidst the sense of novelty, there was a frequent sense of having seen it all before.

Life in China was exhilarating, mind-boggling, frustrating at times. But amidst the sense of novelty, there was a frequent sense of having seen it all before.

The regulations forbidding foreign words on billboards in China reminded me of the TV ads that used to air in Mexico, making fun of people who used Anglicisms and exhorting us to defend the Spanish tongue. The driving restrictions to reduce pollution in Beijing brought to mind Mexico City’s program of Hoy No Circula, which bans your car from the road one day of the week.

Price, foreign exchange, and press controls were also familiar, surreal contradictions in a country stuck between its revolutionary heritage and its opening to the capitalist world. So, too, were all its huge and inefficient state-owned enterprises.

A smattering of tiny, state-sanctioned opposition parties in China give the impression of political plurality, much like they did in the PRI’s heyday in Mexico. Growing up in Mexico, it was hard to keep up with the various small parties sponsored by the PRI to give the appearance of democracy: the Green Party, the Labor Party, two different Socialist Parties, the Democratic Party, even a Communist Party and several parties with the word revolutionary in their name. China’s roster of parties includes no fewer than five with the word democratic or democracy in their names, all of them of course subservient to the Communist Party.

In both societies, I was struck, too, by the cocky rhetoric toward the United States—including claims of holding the upper hand in the bilateral relationship. In the eyes of the PRI, the U.S. was supposedly beholden to Mexico because of our deep oil reserves, as if we really had a choice about exporting our oil; Chinese leaders like to boast about their trillions in U.S. treasury bonds, as if they had any other options for where to sanitize their currency. Both governments also had a foreign policy based on complicity with rogue states—Mexico and Cuba, China and North Korea.

And in both today’s China and the Mexico of two decades ago, small outbursts of organized dissension—in Chiapas and in China’s far western provinces—are treated as existential threats to the overriding narrative. And high-profile arrests carried out in the name of cracking down on corruption are a preferred manner of taking down political adversaries.

There were three seminal events in Mexico’s transition to democracy that have had recent echoes in China, and should thus keep Beijing’s leaders awake at night.

One was the earthquake that devastated Mexico City in 1985, killing thousands and leaving hundreds of thousands homeless. The tragedy marked the beginning of the end for the PRI, laying bare the party’s corruption, lack of transparency and inefficiency. Mexicans, disenchanted with their government’s inability to enforce safer building codes or respond more forcefully to the calamitous aftermath of the disaster, began organizing themselves to take care of their neighbors and their capital city.

The horrible Sichuan earthquake of 2008 may come to be seen as a similar watershed in modern Chinese history. As was the case in Mexico, the tragedy evidenced a clear shift in the Chinese public’s expectations of their government, in the way they voiced their dissatisfaction and demanded accountability. If anything, the effect in China was perhaps more swift and more pronounced, probably because we did not have social media in 1985, and citizens had less immediate channels for criticism and debate. What was remarkable in both cases was how people long accustomed to a strong state control assumed responsibility for rescue efforts. Volunteers rushed to Sichuan to help, whether by train or car or bicycle, ahead of the government, following their own lead instead of waiting for official direction.

A second key event in the democratic transition of Mexico was the splintering within the PRI led by Cuauhtémoc Cárdenas, son of Lázaro Cárdenas, the revered president famous for nationalizing the Mexican oil industry in 1938. Cuauhtémoc Cárdenas led the left wing of the PRI, the faction that believed the party had lost sight of its revolutionary roots. Cárdenas founded his own party in 1987 after having been passed over as presidential candidate in favor of Carlos Salinas. Although the actual end of one-party rule did not happen in Mexico until 2000 with the election of Vicente Fox of the National Action Party (PAN), it was in effect a postponed transition, one that should have taken place in 1988 when Cárdenas ran against Salinas and by most accounts won the presidential vote—at least before some election-night chicanery threw the election in the PRI’s favor.

You can discern a similar turn of events in China. A princeling of the party, Bo Xilai, challenged Xi, the appointed successor of the state, and was purged for corruption. That purge, in turn, has touched off more anti-corruption purges against competing party leaders—effectively splitting the party. In Mexico, it was the division within the ruling party itself that paved the way for the democratic transition: With the internal political strife, the unions and vested interests that were the traditional backbone of the PRI’s support started hedging, just as in China there emerged strong dissenting factions within the Politburo. This is why Bo Xilai and his ally and former security chief Zhou Yongkang, were such a threat, and why they are both now in prison.

The third event that hastened the fall of the PRI in Mexico was a devaluation of the nation’s currency and a spectacular failure of its banks in a non-performing loans crisis, which required a massive government bailout that drove the last nail in the coffin of the PRI’s pretensions of technocratic excellence. If you are going to ask people to surrender some, or all, democratic niceties in exchange for stability and prosperity, nothing undermines that social contract as much as economic mismanagement and incompetence, especially once people have adopted middle- class expectations and are more connected to the outside world.

There is, of course, disagreement about whether China’s slowing growth, slumping stock market, and indebted companies and banks amount yet to a full-blown crisis. But it’s starting to look awfully familiar to this Mexican, and if Chinese leaders or their opponents want to look for a model or cautionary tale, they might be well-advised to visit Mexico to study what might come next.