The most immediate cause of the dispute between the military and civilian leaders was the arrests of military commanders in a series of investigations, given intensive coverage in the press, in which they and others were charged with conspiring to topple Mr. Erdogan’s government. More than 40 serving generals, almost a tenth of the country’s commanders, are under arrest on charges their supporters call flimsy.

But the battle runs far deeper, pitting a party with religious roots against an institution that has considered itself the guarantor of secular traditions, which underpinned the founding of the modern state in 1923 amid the wreckage of the Ottoman Empire. Suspicions ran deep enough that when asked to explain a murky sequence of events this year, Mr. Erdogan’s officials tapped their shoulders, signifying a general’s epaulets. The gesture was meant to cast blame on a military that his officials deem unduly unaccountable.

Officials said Saturday that there was growing frustration on their part over the military’s fight against a Kurdish-led insurgency in the southeast, which has claimed as many as 40,000 lives and seems to have escalated in past months. On July 14, 13 Turkish soldiers were killed in a clash with guerrillas in Diyarbakir Province, and the issue of rights for the Kurdish minority has proven almost as nettlesome as Mr. Erdogan’s contest with the military.

“The military is not really doing enough from a purely military point of view to prevent these attacks and these losses,” one senior official said, speaking on the condition of anonymity because of the delicacy of the issue. “Something is missing in the planning in our fight against terrorism.”

In some quarters, there was a sense of triumphalism over the resignations, serving as a sign of a military whose influence pales before the past, when it carried out three coups, beginning in 1960, and just 14 years ago drove from power a government that shared some ties with Mr. Erdogan’s Justice and Development Party, known as the A.K.P.

“In the old times when the military and politicians could not get along, politicians used to be given notice and they would be forced to quit,” Mehmet Barlas, a columnist, wrote in Sabah. “Now, the reverse is happening. It is not easy to get used to change.”