News of the firings and detentions came as the U.S. and European Union urged the government to uphold democracy and human rights as it pursues the military officers and anyone else involved in the coup attempt.

The state-run Anadolu news agency said a total of 8,777 employees attached to the ministry were dismissed, including 30 governors, 52 civil service inspectors and 16 legal advisers.

Other media reports said police and military police officers and coast guards were also removed from duty. The government has blamed Friday’s failed coup — which it says killed 208 government supporters and 24 plotters — on backers of a U.S.-based Muslim cleric who has become President Recep Tayyip Erdoğan’s chief opponent.

The situation creates a sticky diplomatic situation — Turkey is a NATO member and key Western ally in the fight against the Islamic State group, but the EU and U.S. expressed alarm Monday about its response to the coup.

Even before the weekend chaos, Turkey had been wracked by political turmoil that critics blamed on Erdoğan’s increasingly heavy-handed rule. He has shaken up the government, cracked down on dissent, restricted the media and renewed fighting with Kurdish rebels.

“This is no excuse to take the country away from fundamental rights and the rule of law, and we will be extremely vigilant on that,” EU foreign policy chief Federica Mogherini said at a joint news conference with U.S. Secretary of State John Kerry.

Turkish Prime Minister Binali Yildirim said a total of 7,543 people had been detained since Friday, including 6,030 military personnel. On Monday, according to Anadolu, prosecutors entered Incirlik Air Base in southern Turkey, which is key to the U.S.-led campaign against the Islamic State group. A Turkish brigadier general at the base has already been detained for his alleged role in Friday’s uprising, and news reports say refueling aircraft that took off from the base helped keep F-16s used by the coup-plotters up in the air.

Though government officials offered reassurances that life has returned to normal, warplanes patrolled Turkey’s skies overnight in a sign that authorities feared that the threat was not yet over.

Anadolu said Erdoğan ordered the overnight patrol by F-16s “for the control of the airspace and security” after a faction within the military launched the attempted coup.

The rebellion, which saw warplanes firing on key government installations and tanks rolling into major cities, was quashed by loyal government forces and masses of civilians who took to the streets. The country’s top military brass did not support the coup.

Yildirim’s voice cracked and he wept as he spoke with reporters after a cabinet meeting and repeated a question his grandson had put to him: “Why are they killing people?”

He said he had no answer, but that Turkey would make the coup plotters answer “in such a way that the whole world will see.”

On Monday, Turkish prosecutors began questioning 27 generals and admirals. Anadolu reported the group includes former Air Force commander Gen. Akin Ozturk, who has been described as the ringleader of the foiled uprising. Ozturk, who was still on active duty and has now been detained, has denied he was involved and insists he worked to quell the uprising in statements to Turkish media.

On Sunday, Yildirim said the coup had failed and life had returned to normal, but he and other officials also urged people to take to streets at night, saying risks remained.

At nightfall, thousands of flag-waving people rallied in Istanbul’s Taksim Square, Ankara’s Kizilay Square and elsewhere. Erdogan remained in Istanbul despite statements that he would return to the capital and address crowds in Kizilay Square.

The government moved swiftly in the wake of the coup to shore up its power and remove those perceived as enemies.

On Monday, security forces continued raiding military facilities in search of suspected plotters. In addition to Incirlik, they searched the Air Force Academy premises and residences in Istanbul, Anadolu reported. It was not clear if any arrests were made.

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

The failed coup and the subsequent crackdown followed moves by Erdoğan to reshape both the military and the judiciary. He had indicated a shake-up of the military was imminent and had also taken steps to increase his influence over the judiciary.

It is not clear how the post-coup purge will affect the judiciary, how the government will move to replace the dismissed judges and prosecutors, or where the trials for those detained would be held.

Deputy Prime Minister Numan Kurtulmus defended the crackdown on judiciary officials in an interview with CNN-Turk, saying many of them would have played a role had the coup attempt succeeded.

The government alleged the coup conspirators were loyal to moderate U.S.-based cleric Fethullah Gulen, whom Erdoğan has often accused of trying to overthrow the government.

Gulen, who lives in Saylorsburg, Pennsylvania, espouses a philosophy that blends a mystical form of Islam with democracy. He is a former Erdoğan ally turned bitter foe who has been put on trial in absentia in Turkey, where the government has labeled his movement a terrorist organization. He strongly denies the government’s charges.

Kerry said the United States would entertain an extradition request for Gulen, but Turkey would have to present “legitimate evidence that withstands scrutiny.” So far, officials have not offered evidence he was involved.

Yildirim said those involved with the failed coup “will receive every punishment they deserve.” Erdoğan suggested that Turkey might reinstate capital punishment, which was abolished in 2004 as part of the country’s bid to join the European Union. German Chancellor Angela Merkel’s spokesman said Monday that Turkey reinstating the death penalty would mean the end of negotiations for the country to join the EU.