In the streets of Bangkok, mobs of middle class Thais who would normally hit the city's massive shopping malls have been hitting the pavement instead. For days, hundreds of thousands of protesters have massed in the streets, demanding the resignation of the prime minister, shutting down airports with their protests, and even laying siege to the main government building. As they camped out in the structure, wearing yellow shirts and bandanas, the color of the Thai monarchy, they left the regal buildings looking more like Woodstock, circa 1968.

The antigovernment demonstrators, calling themselves the People's Alliance for Democracy, were lashing out at the prime minister, Samak Sundaravej, who they claimed was a tyrant who'd violated a range of laws. In truth, however, they were not battling for democracy - they wanted Samak, who was democratically elected, to step down. In addition, they hated him because he was allied with former prime minister Thaksin Shinawatra, whom they accused of massive graft and human rights abuses. Eventually, they got their wish: Last week, the prime minister resigned after losing a controversial court decision.

In the streets, the seas of yellow openly wept with joy. The democrat was deposed.

After being hailed as a democratic success story in the 1990s, Thailand has only gone backward. Rather than settling problems through compromise, Bangkok residents repeatedly take to the streets when things don't go their way. Instead of pushing for freedom, much of the Thai media and civil society has gone mute, or simply battles against elected governments. With so many crises, the Thai military now either steps in, as it did in 2006, or hovers in the wings, threatening to intervene.

The events unfolding in Thailand are part of a gathering global revolt against democracy. In 2007, the number of countries with declining freedoms exceeded those with advancing freedoms by nearly four to one, according to a recent report by Freedom House, an organization that monitors global democracy trends.

And the villains, surprisingly enough, are the same people who supposedly make democracy possible: the middle class. Traditional theories of democratization, such as those of Harvard professor Samuel Huntington, predict a story of middle class heroics: As a country develops a true middle class, these urban, educated citizens insist on more rights in order to protect their economic and social interests. Eventually, as the size of the middle class grows, those demands become so overwhelming that democracy is inevitable. But now, it appears, the middle class in some nations has turned into an antidemocratic force. Young democracy, with weak institutions, often brings to power, at first, elected leaders who actually don't care that much about upholding democracy. As these demagogues tear down the very reforms the middle classes built, those same middle classes turn against the leaders, and then against the system itself, bringing democracy to collapse.

This is a process now being repeated in Africa, Asia, and parts of Latin America, regions that once seemed destined to become the third and fourth waves of global democratization, following the original Western democracies and the second wave in southern Europe and several other regions. The pattern has become so noticeable - repeated in Venezuela, Russia, Bangladesh, and other states - that one must even wonder about democracy's future itself.

. . .

For decades, Thailand was ruled by military regimes - the country had so many coups that Thai friends told me they could no longer remember the number. But by the late 1980s, the Thai middle class was growing wealthier and tired of authoritarian rule and joined students in openly contesting its power. In the early 1990s, protesters came out in force in the streets of Bangkok, in the "cellphone revolution" - thousands of businessmen in natty suits, housewives with pots of curry for demonstrators, and students from Thailand's elite universities.

The military acquiesced, seemingly for good, and the country entered a period of democratization. The middle class wrote a new, liberal constitution, which enshrined a wide range of freedoms and provided new checks and balances to prevent the return of authoritarian rule. Thais participated in free elections, while a bonanza of new NGOs, mostly made up of younger urban middle class Thais, sprung up to take advantage of the glasnost. Bangkok seemed in a state of excitement; I was living there at the time, and my Thai friends were always shuttling to meetings to hash out the new charter or write an opinion column. Even foreigners seemed thrilled: I hosted a constant parade of young Americans at my house who'd come to Bangkok to work for a myriad of new NGOs.

The 1990s were a good time in other nations as well. In Latin nations like Chile and Argentina, the urban middle class battled decades of dictatorship, ultimately prevailing in the 1990s. In South Korea, Indonesia, and Taiwan, urban middle class students often led the protests that, ultimately, drew in broader participation and helped bring down dictatorships. Once established in power, these middle classes transformed the Asian nations, so that, in Indonesia, for example, reformers quickly insisted upon laws that increased federalism, devolving power in a society ruled for years by an opaque autocrat.

But what many theorists didn't count on was that middle class excitement could turn sour. In 2000, Thailand's middle class faced a problem it might not have anticipated - a politician who actually canvassed the poor for votes. Thaksin Shinawatra, a billionaire telecommunications tycoon turned pol, traveled the rural hinterlands, spewing populist promises unlike anything the country had ever seen: cheap, government-backed healthcare, loans to every village, and many more. When I traveled with Thaksin on the campaign trail, villagers welcomed him like a kind of god, gathering in packs to listen and try to touch him. And the rural poor, who make up the majority of the country, voted. In 2001, and again in 2005, Thaksin swept elections, winning far greater control of parliament than any previous prime minister.

But Thaksin then used his power to undermine the opposition parties, attack media outlets he did not like, and even launch a "war on drugs" in which more than 2,000 people were killed, including many innocents with political links. "People just disappear every night - we never see them again. People here are terrified just to go to sleep," said Hama, a community activist in southern Thailand, where the killings and disappearances have hit hard. (Hama goes by one name.)

Thaksin was only following a charted course in new democracies that can't yet stand up to "elected dictators." In Venezuela, Hugo Chavez has employed a similar strategy, using his elected power to increasingly muzzle opposition. (Chavez, though, recently overstepped by trying to pass a referendum to change the constitution, which was defeated.) Across sub-Saharan Africa, from Nigeria to Rwanda, many leaders, the first generation of democratically elected presidents, also have turned out to be less than democrats. In Rwanda, president Paul Kagame has amassed so much power that, in its most recent annual report on the country, Human Rights Watch warned of a litany of abuses, including "harsh official repression," disappearances, and unexplained political killings. In Nigeria, supposed reformer Olusegun Obasanjo, elected after years of military coups, used his time in his office to attempt to change the constitution to give him more terms, and then to install a man in power loyal to him. So, too, in Central Asia, where even Kyrgyzstan, once the region's democratic hope, has turned increasingly authoritarian.

Most dangerously, in Russia, where weak democracy in the 1990s built few checks and balances, Vladimir Putin has utilized a blend of populism and nationalism to essentially install himself as an elected dictator. And unlike many of these other nations, Russia can serve as an example - as a powerful, relatively rich authoritarian state under Putin, it has funded NGOs across Central Asia, most of which in theory are designed to promote democracy, but whose true function is to help established rulers push back against democrats in those nations.

"Russia under Putin has put on the front burner the creation of Kremlin-sponsored organizations, such as Nashi, that have the veneer of genuine NGOs but are actually designed to obstruct open political discussion," says Chris Walker of Freedom House.

In democracies still on unsure footing, weak institutions prove unable to hold these elected tyrants back. In Russia, Kyrgyzstan, Rwanda, and many other nations, the media eventually submitted. The Thai media, too, found it tough to fight back against the rich and influential Thaksin. Newspaper after newspaper submitted to threats, suits, or coercion from Thaksin's allies.

Or, if these opponents do not submit, the democratic autocrats turn to force. In Cambodia, where long-serving Prime Minister Hun Sen has used elections as a winner-take-all proposition, essentially wiping out all opposition, the few powerful opponents left are the noisy NGOs monitoring graft and human rights.

In these tough circumstances, the middle classes must decide how to face down growing autocracy. With a leader in power they hate, or their confidence in democracy undermined by the graft or tyranny of some of their own elected leaders, members of the middle class sometimes turn against the very project they shed sweat and blood for. In country after country, many in the middle class have been surprised to discover that a vote could actually empower groups they do not trust. And once the elected populists start pushing the middle class around, it is natural to wonder whether maybe democracy wasn't such a great idea.

Of course, in some cases elections bring to power populists who genuinely respect democracy - or leaders who, despite their problems, don't actually spark a middle class revolt, perhaps because they are also delivering staggering economic growth, like Putin. But when these elected populists ignore the middle class, tarnish democracy, and deliver little else, chaos breaks loose.

In Bangladesh, freer votes in the 1990s and early 2000s left the country in the hands of two venal, populist leaders, Sheik Hasina and Begum Khaleda Zia, both of whom allegedly engaged in massive graft and relied on thuggish supporters to beat their opponents, according to a range of human rights groups. Fed up with the two women, many elites in Dhaka welcomed a military intervention two years ago - at least initially.

Similarly, in Venezuela an urban middle class used to dominating politics has long chafed at the rule of Hugo Chavez, and many Caracas elites threw their support behind a short-lived coup in 2002. In Russia, many of the educated urban dwellers deplore Putin, but his political strategy, and Russia's growth, have been so successful that they have little influence, leaving the few remaining liberal opposition parties to appear almost comical in their powerlessness.

Eventually, in many of these weak democracies, members of the middle class place their hopes in the very men they once deplored, realizing they trust the army officers, who tend to come from the same elite backgrounds, more than they trust the newly empowered poor. In Bangladesh, Fiji, Pakistan, Mauritania, Venezuela, and many other states, the military tries to step in, claiming that it must intervene to restore "order," which usually means a return to old elite rule.

Often, the middle class throws garlands. In Thailand, literally - Bangkokians tossed flowers at soldiers in the 2006 coup. And while in the early 1990s young Bangkokians called friends on their cellphones to organize pro-democracy protests, in 2006 they did just the opposite: The streets swarmed with young Thais posing for smiling photos next to the men with guns.