Chiefs of general staff, army, navy and air force take 'early retirement' in protest at detention of 250 officers

Turkey's military is in turmoil after the country's four most senior commanders quit in protest over the detention of 250 officers on charges of conspiring against the government.

General Işık Koşaner, the chief of general staff, stepped down on Friday night along with the army, navy and air force commanders, plunging Nato's second-largest army into uncertainty shortly before a senior promotions board convenes.

In a farewell message to "brothers in arms", Koşaner said it was impossible to continue in his job as he could not defend the rights of men who had been detained as a consequence of a flawed judicial process.

The prime minister, Recep Tayyip Erdogan, swiftly appointed General Necdet Ozel, formerly commander of the military police, as the new head of the military.

The collective "early retirement" of the top four came hours after a Turkish court charged 22 suspects, including several generals and officers, with carrying out an internet campaign aimed at undermining Erdogan's Justice and Development party (AKP) government. Miltary chiefs have repeatedly denied the existence of plans for the so-called Sledgehammer coup.

"There are two important reasons for this move", Cengiz Aktar, professor for EU relations at Istanbul's Bahcesehir University, told the Guardian. "On the one hand the AKP government's increasing interference in the appointment of military personnel – which was previously handled solely by the military itself – and on the other hand the arrests in the Sledgehammer coup trials."

The government's relations with the military, who regard themselves as the guardians of the secular Turkish republic, have been strained ever since the Islamic AKP came to power in 2002.

In a move aimed at decreasing the power of the military, the Turkish Grand National Assembly passed decisive reforms in 2003 assuring a civilian majority in the traditionally military-dominated Security Council (MSK). When the ruling AKP proposed Abdullah Gül as its presidential candidate in 2007 the military published a text on its website stating that the Turkish military would "defend secularism in Turkey by all means."

The Turkish military had staged coups in 1960, 1971, 1980 and 1997, forcing the ruling government to resign. But the AKP government confidently defied the 2007 "e-coup" and former AKP politican Gül was voted to become the next Turkish president.

In a first reaction to the military resignations from the main opposition Republican People's party (CHP), deputy chairman Gürsel Tekin said: "The law clearly states how generals should be promoted. It's a pity that the government does not care about the laws. The government wants to redesign the military along their own lines. As a reaction to this the generals have resigned."

Kemal Kilicdaroglu, the head of the CHP, has interrupted his summer holidays to return to Ankara.

Following the resignations, Erdogan met with the head of the gendarmerie (military police), Necdet Özel, the only high commander who remained in office.

While Turkish news outlets dubbed the situation a "bomb" and a "political earthquake", several political analysts argued against overreaction. "The situation has clearly become intolerable for the military forces and they subsequently resigned," Cengiz Aktar told the Guardian. "This is nothing to make too much of a fuss over; these things are bound to happen in a democracy."

• This article was corrected on 3 August 2011 because the original said the Turkish military had staged a coup in 1991.