The verdicts involving 224 suspects took place at a court in Sincan prison in the capital, Ankara.
The accused were on trial on charges of crimes against the state, leading an armed group, attempting to assassinate the president, and the deaths of 249 people. The trial started in 2017.
“Aggravated” life sentences for the 17 are the harshest prison terms in Turkey since it abolished the death penalty in 2002, as there is no chance of parole and conditions are extra harsh.
Gulen has denied any role in the failed coup, which left 251 dead and more than 2,000 wounded. Turkey has failed to secure his extradition.
Among the defendants was former Air Force Commander Akin Ozturk, who was accused of leading the Peace at Home Council, which allegedly coordinated the mutinous soldiers. He was the top suspect after Gulen.
State-run Anadolu news agency said life sentences given to people accused of being the ringleaders of the attempted putsch also included Ali Yazici, who was President Recep Tayyip Erdogan‘s military aide.
Reporting from Istanbul, Al Jazeera’s Hashem Ahelbarra said Thursday’s trial was one of the most important among those held in Turkey since 2016 because it implicates Ozturk and Yazici as key players.
“They are accused of attempting to overthrow the government and for ceasing the headquarters of the military,” said Ahelbarra. “This explains why today they received some of the heaviest penalties handed down to the defendants.”
He noted that Ozturk also faces another trial relating to his alleged role in attacks on the Turkish parliament.
“The upcoming trial is about the Akinci airbase in Ankara and one of the key defendants in the case is once again Akin Ozturk – who is accused of giving orders to fighter jets to take off from there and drop bombs onto the Turkish parliament in Ankara,” said Ahelbarra.
Twenty-six generals among those on trial also included Lieutenant-Colonel Levent Turkkan, who was the aide to then-Chief of Staff General Hulusi Akar. Akar was appointed defence minister in July 2018.
Of the defendants, 176 were now under arrest, 35 tried in absentia, and 13 still at large, Anadolu said. The trial of the 13 considered fugitives will continue separately.
There were heightened security measures outside the courtroom as drones flew above.
In April, Erdogan said that, in total, 20,226 people have been convicted on charges related to the coup attempt.
He said more than 31,000 people have been sacked from the police, 15,000 from the military, and 4,000 from the judiciary in its aftermath.
Since July 2016, tens of thousands of people have been arrested over alleged links to the coup under a two-year state of emergency that ended last year.
But nationwide raids by police have continued and there are almost daily reports of public prosecutors issuing detention warrants for suspects over Gulen ties.
Nearly 290 coup-linked court cases have been launched, 261 of which ended with 3,239 defendants convicted, according to justice ministry figures.