His populist style - Demirel was known as "Sulu the shepherd" because of his village background - and his canny use of the symbols of Islam proved a vote-winner in the conservative countryside, where most Turks lived.
His government had to balance the demands of its rural support base with the need to push Turkey into the industrial era.
The balancing act seemed to be working in the mid-1960s, with annual growth of around six percent a year as electricity and roads reached corners of Turkey that had never seen either.
But by 1970, Demirel was on the defensive as rising political radicalism brought social unrest.
Demands for reform
On the left, students and workers groups demanded radical reform, while Demirel was being outflanked on the right by new nationalist and pro-Islamic parties.
When the ideological conflict started to turn violent, Turkey's powerful military intervened. Generals issued an ultimatum that forced Demirel out of office in 1971 in the so-called coup by memorandum.
Successive governments, led first by military-backed technocrats and then by Demirel's great rival Bulent Ecevit, failed to get a grip on the rising violence, which worsened in the 1970s as Turkey's economy, hit by the oil price crisis, slumped into crisis.
| Demirel launched his political career after the 1960 military coup that deposed the Menderes government [Anadolu/Getty Images] |
Many blamed Demirel for turning a blind eye to his nationalist coalition partners, who openly incited violence that saw dozens killed weekly in clashes between left- and right-wing gangs.
Turkey was heading towards another military coup, which arrived in 1980.
Account of coup
According to late journalist Mehmet Ali Birand's account of the coup, Demirel was on the telephone to his interior minister on the night of September 11, 1980, when the line went dead.
Looking out of the window of the prime minister's residence, he saw that his usual bodyguards had been replaced by armed soldiers.
"It is a pity, a pity for the motherland, a pity for us all," the outgoing prime minister said, before packing his bags for prison.
Demirel was banned from politics, but the ban was repealed in the late 1980s.
He became prime minister again in 1991, and president in 1993 on the death of Turgut Ozal.
As president, Demirel fostered ties with the Turkic republics of the former Soviet Union, and took credit for brokering the peaceful removal from power of an Islamist government under pressure from the secular-minded military in 1997, at a time when many feared a coup.
The toppling was later dubbed Turkey's "postmodern coup".
Source: Agencies