Almost immediately after Friday night’s coup attempt in Turkey began to falter and scenes of pro-uprising soldiers surrendering their weapons started to pour in, Turkey’s leadership promised that the plotters would pay the highest price.

“As you know the death penalty had been removed from our legal system. We will discuss… what further measures we should take to prevent such future attempts,” Prime Minister Binali Yildirim said on Saturday morning when the arrests of pro-coup officers and soldiers were in full swing across the country.

“This uprising is a gift from God to us because this will be a reason to cleanse our army,” President Recep Taiyp Erdogan stated earlier on Friday night, addressing a large and desperate crowd of his supporters.

Read more

The overnight coup attempt has been the latest, but not the first, in a string of Turkish military uprisings throughout the decades, exposing the complicated relationship between the army’s leadership and Islamist-leaning President Erdogan.

The tensions between the military and Erdogan span back as long as his political career. In 1997, senior army officers pressured then-Prime Minister Necmeddin Erbakan to step down because he advocated for strengthening Islamism across Turkey and turning away from the West. Erdogan, an Erbakan supporter who was then mayor of Istanbul, was arrested and banned from pursuing a political career for five years for reading out a nationalist and Islamist poem in public at the time.

The most significant crackdown on the military to date came in 2010, when the so-called Ergenekon trials were launched.

The 2,455-page indictment listed dozens of charges against 275 defendants, including several generals and high-ranking officers, accusing them of being members of an alleged clandestine ultranationalist network called Ergenekon, which, according to the court, had conspired to overthrow Erdogan’s government.

Life sentences were given to former armed forces chief General Ilker Basbug, former army commander Hursit Tolon, and several other retired generals and colonels. The case was opened in 2007 when 27 hand grenades were discovered in a house in Istanbul.

The existence of Ergenekon was never proven, but accusations soon began circulating that the explosives had been intended to be deployed in a coup attempt.

Since Erdogan’s ruling Justice and Independence Party (AKP) came to power in 2002, the government has taken a number of legal moves to control the military’s domestic expenditures and policies.

The army responded with counter-measures in a bid to weaken Erdogan’s government. In 2007, the General Staff spoke out against then-Foreign Minister Abdullah Gul becoming AKP’s presidential nominee, arguing that selecting a politician whose wife wore an Islamic headscarf would undermine the secularist values of Turkish democracy.

After Gul took office in 2007, some top army generals avoided participating in official events where First Lady Hayrunnisa Gul was also be present.

The Turkish military is widely thought of as the guardian of Turkish secularism, standing in opposition to the Islamization of the country. The tradition goes back to the times of Mustafa Kemal Ataturk, a former army officer who transformed the late Ottoman Empire into the modern and largely secular republic it is today.

WATCH MORE: