ISTANBUL - An Istanbul court on Wednesday ordered the release of all the suspects in a hugely controversial trial of 22 students from a prestigious Istanbul university who protested on campus against President Recep Tayyip Erdogan’s military campaign in Syria.

Fourteen of the students had been held in jail on charges of disseminating “terror propaganda” after their initial detention in March when police stormed dormitories at Bogazici University.

But after an emotionally-charged first trial hearing, the judge ordered that the 10 young men and four young women be released.

The order sparked scenes of jubilation in the packed courthouse, with families crying in jubilation and relief, an AFP correspondent said.

The other eight defendants had been free - but still charged - ahead of the trial Wednesday.

All 22 now remain charged and under judicial supervision, which means they are subject to certain restrictions and should report to the authorities.

The judge set the next hearing in the case for October 3. They were due to walk free later Wednesday.

The accused face jail terms of up to five years if convicted on charges of propaganda for the outlawed Kurdistan Workers Party (PKK).

Turkey earlier this year successfully carried out a major incursion into the Afrin region of northern Syria with allied Syrian rebels. The offensive ousted the Kurdish People’s Protection Units (YPG) militia, which Ankara brands a terror group and branch of the PKK.

A day after Afrin was taken, a group of students opened a stand on the campus handing out sweets they dubbed “Afrin delight” in memory of the Turkish soldiers killed in the operation.

But another group unfurled a banner with the words “There’s nothing sweet about occupation and massacre,” in a show of protest. Erdogan then slammed the anti-war students as “terrorists”.

Turkish prosecutors accuse the students of seeking to discredit the army and the state by portraying them as an “occupier” and as an “illegitimate force that uses violence.”

The case was condemned by rights activists, who saw the prosecution as the punishment of sometimes teenage suspects who had only expressed their political views.

Giving testimony in court, the students rejected the charges and argued shouting slogans against the government or in favour of promoting peace had nothing to do with the PKK.

“I didn’t praise violence or make terror propaganda,” accused student Sukran Yaren Tuncer told the judge.

“I shouted slogans like ‘Shoulder to shoulder against fascism’ and ‘No war, peace now’. They are universal slogans and chanted in every demo.”

Another defendant, Sevde Ozturk, added: “Some slogans were shouted but they can only be seen as political criticism.”

“I reject being stigmatised as a terrorist just because I chanted peace slogans,” she told the court.

Some of the students also accused police of beating them in detention.

Authorities detained hundreds of people during the Afrin operation on terror propaganda charges for criticising the operation, raising new concerns about freedom of speech in Turkey.

Founded in the 19th century as Robert College, Bogazici University is considered a bastion of secular and Western-orientated education in Turkey.

Parents of the students attending the trial said that their children were innocent and their education was being unfairly disrupted.

Tevfik Tulay, father of arrested third-year engineering student Uzay, told AFP his son was “now deprived of all his rights to education”.

“There is no evidence, he was curious what was going and stayed there merely as a spectator.”

Ozgur, whose 18-year-old student Yaren has been held since March 25, said: “I am here to take her home.”

“She is innocent. She was taken just because she stood on the right or on the left of a banner,” the mother said.