Following a failed coup against Turkish President Recep Tayyip Erdogan, the government moved swiftly Sunday to shore up his power and remove those perceived as an enemy, saying it has detained 6,000 people.

The crackdown targeted not only generals and soldiers, but a wide swath of the judiciary that has sometimes blocked Erdogan, raising concerns that the effort to oust him will push Turkey even further into authoritarian rule.

Friday night’s sudden uprising by a faction of the military appeared to take the government — and much of the world — by surprise.

The plotters sent warplanes firing on key government installations and tanks rolling into major cities, but it ended hours later when loyal government forces regained control of the military, and civilians took to the streets in support of Erdogan. At least 294 people were killed and more than 1,400 wounded, the government said.