A Turkish court has handed down life sentences to dozens of people accused of attempting to assassinate President Recep Tayyip Erdoğan, in one of the highest-profile trials dealing with last year’s attempted military coup.

Nearly 50 defendants stood trial in Muğla, near where soldiers in helicopters stormed a resort hotel where Erdoğan was on holiday in July 2016, just minutes after the Turkish leader had fled. The suspects, who were accused of orchestrating the ambush, include the president’s former military aide and other senior officers.

The court sentenced 40 to life in prison, with some receiving aggravated life sentences, reducing the possibility of parole. “Defendants have been found guilty of the charge of attempting to assassinate the president,” Judge Emirsah Bastog told the packed courtroom, according to Reuters.

The case in Muğla, which began in February, is one of several trials taking place around the country over the attempted putsch, in which helicopters and fighter jets took to the skies of Ankara and Istanbul and tanks rolled into the streets of Turkey’s largest cities as part of an attempt to oust Erdoğan.

The coup was beaten back, but 250 people were killed, more than 2,000 injured and the country’s parliament was bombed in a traumatic episode that Turkey has yet to come to terms with.

Erdoğan was on holiday in the resort town of Marmaris when the plot began, and barely escaped from the hotel before it was stormed by coup soldiers. He would go on to address the country through the mobile phone application FaceTime, urging ordinary citizens to take to the streets to defend democracy.

The government blames a movement led by Fethullah Gülen, an exiled preacher now based in the US with thousands of grassroots followers, for orchestrating the coup attempt, and has sought the reclusive cleric’s extradition.

The plot was followed by wide-ranging crackdown that has led to tens of thousands of people being imprisoned or dismissed from their jobs in the judiciary, civil service, military, police, media and academia, a purge that has gone beyond the alleged coup plotters to encompass dissidents of all stripes.

The trial in Muğla involved 47 suspects, including two who remain at large. Ali Yazıcı, Erdoğan’s former military aide, was sentenced to 18 years in prison.

The accused protested that they had not been treated fairly. One former lieutenant said they had been treated like criminals from the moment of arrest. Another said the trial was unfair, and that the defendants were “just the grass that elephants trampled on during the fight”, according to a Reuters report from inside court.

Facebook Twitter Pinterest Supporters of President Erdoğan wave Turkish flags during the trial. The placard reads: ‘We want execution!’. Photograph: Osman Orsal/Reuters

The crackdown on alleged plotters continued this week, as prosecutors issued 140 arrest warrants for education and youth ministry staff on Tuesday and another 112 warrants for former municipal workers accused of links to the Gülen movement.

The broad crackdown has polarised Turkey after a brief moment of unity in the aftermath of the coup, when all political parties condemned and opposed the putsch. Opponents of Erdoğan say he took advantage of the coup plot to consolidate his power, purging dissidents and persecuting critical media outlets.

Earlier this year, a referendum that expanded the president’s powers was narrowly approved by voters, setting the stage for national and presidential elections in 2019.