This column contains a correction.

Three weeks ago, Prime Minister Recep Tayyip Erdoğan was set to enter the history books as Turkey’s most successful politician since the Republic’s founding father, Mustafa Kemal Atatürk. But bad mismanagement of a fortnight of urban protest has irreparably damaged Prime Minister Erdoğan’s political legacy and his party.

What began as a modest demonstration of concerned environmentalists in Istanbul’s city center has evolved into a much broader protest, reflecting accumulated anger over increasingly restrictive government policies and disproportionate police action, which has resulted in four deaths and 7,500 injuries. One of the United States’s closest allies has just failed a major leadership test.

The prime minister and his allies made three political mistakes. First, Prime Minister Erdoğan refused to accept that protest as a legitimate and necessary part of an open society, instead missing out on an opportunity to deepen Turkey’s democratic exchange. Second, the Justice and Development Party, or AKP, underestimated concerns of the middle class about restrictions on freedom of expression, new alcohol regulations, the prime minister’s increasingly despotic leadership style, and the outsize role of the state in average Turks’ lives. Third, the prime minister’s aggressive rhetoric was laden with thinly veiled conspiracy theories and threats. He repeatedly distinguished between the “real Turkey,” consisting of his supporters and the “extremists” that he and his cabinet characterized as terrorists. All of this served to deepen existing divisions within Turkish society.

Prime Minister Erdoğan’s uncompromising streak was well known before the protests, but the extent of his miscalculation was a surprise. The prime minster left for Africa in the early hours of the protest, accepting an honorary doctorate in Algeria while Istanbul was shrouded in tear gas. Even sympathetic observers agree that he and his party are becoming victims of hubris after a decade in power and several resounding electoral victories.

The use of police violence in response to political protest—observed firsthand by CAP’s Matthew Duss during a recent trip to Istanbul—served as a stark reminder of Turkey’s deep internal political divisions. The prime minister wasted good opportunities to de-escalate the conflict, and despite some conciliatory remarks, none of the more moderate AKP leaders dared to challenge him. One renowned Turkish commentator argued that “the government and its hard core supporters are proving that they do not have the mental capacity to understand what is really happening.”

Maybe it’s time for the AKP leadership to learn Portuguese and follow Brazil’s lead.

When similar protests erupted in several Brazilian cities last week, driven by middle-class demands for more reliable transportation and better governance, police responded with a harsh crackdown resembling the one that occurred in Taksim Square. But Brazil’s political leaders reacted very differently. President Dilma Rousseff struck a conciliatory tone, stating she was “listening to the voices calling for change” and admitting that “Brazil has woken up a stronger country” after the protests. She called off a diplomatic trip to Japan and announced an emergency cabinet meeting to discuss the unrest. President Rousseff also acknowledged legitimate grievances and the right to protest, while opening a dialogue with protesters, thereby defusing the situation—in stark contrast to Prime Minister Erdoğan’s response.

These disparate reactions show the importance of inclusion and responsiveness in the mass politics in today’s rising democracies. Brazil and Turkey have roughly the same per-capita income, both shook off military rule in the 1980s, both are important strategic partners to the United States, and both have experienced rapid economic expansion over the past decade, lifting 40 million Brazilians out of poverty and growing Turkey’s gross domestic product by more than 40 percent. But Brazil’s politics has been shaped by a policy of social inclusion and free expression. At virtually every level, officials have echoed the message of President Rousseff, who conceded that it was “befitting of youth to protest.” This explosion of popular anger caught both governments by surprise, but the reaction of Brazil’s political leaders was pragmatic, smart, and open-minded.

In Turkey, on the other hand, the AKP leadership showed no such confidence in the population and reacted with outlandish conspiracy theories, paranoia, and threats against its own citizens. The foreign minister accused certain “circles” of trying to damage Turkey’s image, questioning journalists’ motives for reporting on the protests. Prime Minister Erdoğan lashed out at CNN, Reuters, and the BBC for what he called “fabricated news,” and reacted angrily to criticism from the European Parliament, saying that “there is a price for talking so freely and boldly about Turkey’s domestic affairs.”

Later, the Turkish Radio and Television Supreme Council fined a number of channels for “harming the physical, moral and mental development of children and young people” by covering the protests. Given Turkey’s recent history of curbing freedom of expression, the AKP’s response to the protests has created an atmosphere of division and intimidation. Again in sharp contrast to Turkey, freedom of speech is enforced by law in Brazil, and censorship is widely condemned by politicians and civil society alike. In spite of several unsolved violent crimes against journalists, President Rousseff has made an effort since taking office to reaffirm constitutional protections for the freedom of information.

The Turkish government’s conspiracy theories also demonstrate its tendency to stifle dissent and project domestic political paranoia abroad. Foreign Minister Ahmet Davutoğlu demanded that Turkish embassies abroad report “which efforts these countries took to create a perception against Turkey.” Dissent is condemned as an attack against Turkey itself and dismissed as the result of foreign meddling. Interior Minister Muammer Güler also revealed the AKP’s inability to grapple with dissenting opinion when he asserted that social-media users had “passed on false information to provoke the demonstrations,” adding that those “who manipulate public opinion and guide demonstrations on Twitter and Facebook will be revealed.” Social media has become the new enemy of the state.

The tradition of blaming the “other” has risen to new heights in Turkey. After returning from his trip to Africa, the prime minister accused financial investors of encouraging the protests. Prime Minister Erdoğan said that an “interest-rate lobby” is “threatening Turkey with speculation,” adding that this group “has exploited the sweat of my people for years.” These barely disguised anti-Semitic themes have a long history in populist politics; even moderate elements of the Turkish cabinet joined in. Finance Minister Mehmet Şimşek was quoted as saying “there are factions that are trying to benefit from countries’ situations like this,” while U.S.-educated Deputy Prime Minister Ali Babacan added that “the interest-rate lobby knows who they are.” Some analysts have dismissed these statements as a nuisance, but rhetoric matters. The “interest-lobby” debate and distinctions between predatory and producer capitalism were core features of 20th century right-wing propaganda against so-called “Jewish finance capitalism.”

The Turkish leadership has lost its political and moral compass over the past three weeks. Demonstrations that at first represented a moderate challenge to AKP policies have exposed a paranoid streak. The prime minister and his party have failed this leadership test, even if the AKP shores up its near-term political situation. According to columnist Semih Idiz, “none of [Prime Minister] Erdoğan’s sensible advisers—and there must be some—have the courage to tell him that this negative image of Turkey is not part of an international conspiracy but is of the government’s own making for mismanaging what started off as a simple protest to protect trees.”

The AKP leadership fails to see that a pluralist democracy is the only viable option for Turkish society. This failure of leadership will change the course of political confrontations in Turkey and affect Turkey’s role in the Western alliance: Europe has delayed negotiations on Turkish accession into the European Union. And, just weeks after receiving Prime Minister Erdoğan in Washington, President Barack Obama and Secretary of State John Kerry must be wondering if it is time to review the U.S. relationship with Turkey as well.

Michael Werz is a Senior Fellow at the Center for American Progress.

* Correction, June 27, 2013: This column incorrectly stated the increase in Turkey’s gross domestic product. The correct amount of increase is more than 40 percent.