At Diyarbakir, another Turkish base, the Air Force began staging small numbers of American troops last fall to recover any downed pilots or flight crews. The Pentagon’s plans to place a mobile rocket system known as Himars, short for High Mobility Artillery Rocket System, somewhere in Turkey to support United States operations in Syria could also be in jeopardy.

The Turkish military, which sees itself as the guardian of the secular state, has overthrown or forced out four elected governments since 1960. Turks have long been fascinated by what they call “the deep state”: a murky group of operatives, linked to the military, thought to have battled perceived enemies of the state since the Cold War.

But in a striving Turkey of thriving capitalism and a still boisterous news media, memories of the damage to democracy fomented by past coups remains strong. In the first coup of 1960, the military tried the prime minister and president for treason. The 1980 “September 12 Coup” helped end a period of anarchy and terror, but not before thousands of people were arrested and dozens were executed and tortured.

Analysts said the latest coup attempt underlined the extent to which elements within the military had become frustrated by Turkey’s direction under President Recep Tayyip Erdogan, a religious and conservative Muslim. Mr. Erdogan came to power in 2002, pledging to declaw the once powerful military. He proceeded to impose civilian rule over the state by putting dozens of prominent generals and officers in prison after dramatic show trials for treason, often on tenuous and even fabricated evidence.

Moreover, Mr. Erdogan, whose government once promised a foreign policy of “zero problems with neighbors” has seen conflicts multiply, including 14 attacks on Turkey in the past year by Kurdish and Islamic State militants. He has presided over an increasingly shaky economy, and alienated allies from the United States to Russia. His government has been mired by accusations of corruption.

American and NATO officials have been pressing to insulate the mission against the Islamic State at Incirlik and other Turkish bases from the internal upheaval. But even if they succeed, Turkish politicians and security forces are likely to be, at the very least, distracted from their counterterrorism focus despite recent vows to redouble efforts after last month’s Istanbul airport bombing.