Turkey’s prime minister, Recep Tayyip Erdogan, was in Brussels last week seeking to repair relations with Europe, but the first place to look for a solution is within himself. Once hailed as the leader of a model Muslim democracy, he has created a political disaster at home, transforming Turkey into an authoritarian state that poses dangers not just for itself but for its allies in NATO, including the United States.

The latest turmoil has its roots in a political war between Mr. Erdogan’s Justice and Development Party and his former close allies who follow Fethullah Gulen, a moderate Islamic scholar who lives in Pennsylvania. The tensions erupted into the open last month with a corruption probe that led to the resignation of four government ministers and threatened to ensnare Mr. Erdogan’s family. The prime minister called the probe a “coup attempt” and blamed a “secret organization” within the judiciary and police directed by the Gulen movement and serving “foreign powers” like the United States and Israel. The government has since purged hundreds of police officials and prosecutors and sought to assert control over the judiciary. It also drafted legislation expanding the government’s power to appoint judges and prosecutors, further breaching judicial independence, and has prevented journalists from reporting freely. All the while, Mr. Erdogan has spewed endless conspiracy theories and incendiary rhetoric, even hinting at American treachery and suggesting that the American ambassador might be expelled.

The probe and Mr. Erdogan’s reaction may well be politically motivated. There are important local elections in March. But Mr. Erdogan should be insisting that the probe be fair and transparent, not trying to derail it. His ruthless ways and his attempt to crush dissent are not new, as the crackdown against demonstrators during protests last June showed. Such actions trample on democratic reforms demanded by the European Union as part of Turkey’s bid for union membership, which may be more in peril than ever, and they are increasingly at odds with the ground rules for NATO members.

Germany’s foreign minister, Frank-Walter Steinmeier, was right when he said in Brussels that the Europeans must demand that Turkey return to the rule of law. The Obama administration also needs to send a strong message about the damaging course Mr. Erdogan is pursuing. Whether Turkey nurtures its hard-won democracy, which has contributed to its impressive economic growth, or turns authoritarian is as critical to regional stability and to its NATO allies as it is to Turks.