Turkish President Recep Tayyip Erdogan greets supporters as he leaves his residence in Istanbul on Monday. (Kayhan Ozer/Presidential Palace via Reuters)

As it became clear that the coup attempt launched by a Turkish military faction Friday night had failed, the commander of Turkish forces at Incirlik Air Base approached his American counterparts there and asked for U.S. asylum, according to Turkish and U.S. officials.

Gen. Bekir Ercan Van was told that the United States was in no position to discuss a request, since legally it can consider asylum only for those already on American soil, the officials said.

Van and other Turkish officers and airmen on the base are among the thousands of military personnel now under arrest in the aftermath of the attempt to overthrow the government of President Recep Tayyip Erdogan.

The arrests or firing of nearly 20,000 armed forces members, police, judges and bureaucrats, amid ongoing government crackdowns on the press and political opponents, have left the United States and its NATO allies walking a fine line between condemning the insurrection and warning Erdogan not to take his revenge too far.

At stake is Turkey’s crucial role in the fight against the Islamic State. Incirlik, where Turkish tankers reportedly took off to refuel aircraft flown by the plotters during the coup attempt, is also the home base of many of the U.S. aircraft bombing the militants in Syria and Iraq.

Turkey’s long border with Syria has for years been the main transit point for resources and personnel flowing both to U.S.-backed opposition forces in Syria and to the Islamic State and Jabhat al-Nusra, al-Qaeda’s Syrian affiliate. Persuading Turkey to stop the militant traffic, facilitate assistance to the moderate Syrian opposition and use its own forces to protect the border area has long been the subject of a delicate, up and down dialogue between U.S. and Turkish diplomats and military officials.

U.S. military flights at Incirlik, shut down while the aborted plot was still in progress, have been restarted, and operations are proceeding normally, although outside electricity to the base remains cut. Defense Department spokesman Peter Cook said all U.S. munitions were secure, and he denied reports that any had been taken by the plotters. About 3,000 U.S. personnel are based at Incirlik and another Turkish base.

Pentagon leaders were still trying to determine what impact the upheaval in Turkey, and the arrest of military officers, would have on U.S.-Turkish defense cooperation.

At the very least, one U.S. military official said, American officials of high and low rank will have to identify which of their Turkish counterparts have been swept out as part of the purges.“Relationships may have to be established, or reestablished,” the official said.

Asked directly whether the United States had any prior knowledge of the coup attempt, White House press secretary Josh Earnest told reporters that he had no “intelligence assessment” to offer. “I think the very definition of the coup is that not many people are aware of a secret plot to overthrow the government.” Cook indicated that senior Pentagon officials first learned it was underway from media reports.

But Van’s asylum request — although it was never seriously considered, according to U.S. officials — is one of a number of elements contributing to Turkey’s suspicion that the attempt was instigated outside the country.

Chief among them is the presence in the United States of Turkish cleric Fethullah Gulen, an Erdogan opponent with many adherents inside Turkey. Gulen, in self-imposed exile since 1999, has permanent U.S. residence and lives in Pennsylvania.

While some here and abroad have argued that the widespread purges are Erdogan’s attempt to consolidate power, Turkish officials said they were necessary to completely rid the government of Gulen’s followers. Both Turkish and U.S. officials spoke on the condition of anonymity about events of the past several days because they were not authorized to make public statements.

Turkish officials said that some military personnel believed to have been directly involved in the coup attempt are still missing, leading to concern that another wave of violence is possible.

Turkish officials repeatedly described the plotters as posing a threat equal to that of the Islamic State and the Kurdistan Workers’ Party, or PKK, the violent separatists who have battled a succession of Turkish governments.

Gulen’s followers are “worse than the Islamic State,” said one official, “because they come from within.”

What has sometimes been seen abroad as Erdogan’s paranoia about internal threats is one of the Obama administration’s chief concerns, particularly when it comes to the two countries’ joint fight against the Islamist militants.

One U.S. official expressed particular concern about border control, as military leaders were removed from one of the main Turkish army units on the Syrian border.

Turkey vowed Monday to continue its counterterrorism efforts against the Islamic State, saying it would separate those actions from the ongoing arrests and coup investigations by creating “counterterrorism cells” within relevant ministries.

“We have replaced people immediately where we had to. For example, the head of counterterrorism police was shot in his head with his hands tied behind his back” by the coup plotters, one Turkish official said.

As U.S. and European officials continued to condemn the coup, their comments Monday shifted markedly to pressing Erdogan to follow the rule of law and maintain democratic principles amid the ongoing government crackdown.

European Union foreign policy chief Federica Mogherini suggested that Turkey’s bid for E.U. membership could be at stake if it reinstates the death penalty, as Erdogan has indicated.

In an interview with CNN, Erdogan said that such a decision had to be made by the Turkish parliament. But, he said, a “clear crime of treason” had been committed, and such legislative action would “never be rejected by our government.”

Secretary of State John F. Kerry, attending a meeting in Brussels that was dominated by talk of events in Turkey, said NATO would “measure” Turkey’s actions, and would be watching in the coming days to ensure that its government fulfills what he called NATO’s “requirement with respect to democracy.”

“Obviously, a lot of people have been arrested and arrested very quickly,” Kerry said. “The level of vigilance and scrutiny is obviously going to be significant in the days ahead. Hopefully, we can work in a constructive way that prevents a backsliding” away from democratic norms. He said that Turkish Foreign Minister Mevlut Cavusoglu, with whom Kerry has spoken almost daily since Friday, has repeatedly assured him that the government will respect democracy and the law.

Turkish Defense Minister Ismet Yilmaz is due in Washington this week for a conference on the anti-Islamic State campaign. Cook, at the Pentagon, said that Defense Secretary Ashton B. Carter had not yet spoken to Yilmaz and that he could not confirm the Turkish minister’s attendance.

Despite Kerry’s reference to NATO’s “requirement,” the alliance has no provision for expressing displeasure over the internal actions of any member. While its initial 1949 document, known as the Washington Treaty, says it was “founded on principles of democracy, individual liberty and rule of law,” and includes a provision for withdrawal from the alliance with a one-year notice, “NATO has no mechanisms to sanction its members,” an alliance official said.

“This is more an issue of peer pressure,” said the official, speaking on the condition of anonymity to discuss the sensitive issue.

While Erdogan publicly insisted that the United States extradite Gulen, Kerry said Washington has received no formal request. Turkey must send “evidence,” he said, not allegations.

“What we need is genuine evidence that withstands the standard of scrutiny that exists in many countries,” he said. “And if it meets that standard, there’s no interest we have of standing in the way of appropriately honoring the treaty we have with Turkey with respect to extradition.”

Erdogan said an official request would soon be on its way. U.S. refusal to deliver Gulen, one Turkish official said, would be equivalent to “punching an ally.”

DeYoung reported from Washington. Carol Morello in Brussels and Missy Ryan in Washington contributed to this report.