An armed student went on a rampage in the Port el-Kantaoui resort near Sousse killing 38 holidaymakers.
A student armed with a Kalashnikov assault rifle and grenades went on a rampage in the Port el-Kantaoui resort near Sousse killing 38 holidaymakers, 30 of them Britons, before being shot dead by police.
It was the second of two deadly attacks on foreigners claimed by the Islamic State group that year which devastated Tunisia's once-lucrative tourism sector.
Security was tight at the Tunis courthouse for Friday's trial opening.
Six of the defendants are policemen accused of failing to assist a person in danger.
The remainder, all Tunisians, are accused of terrorism offences, murder and "conspiracy against the security of the state", the prosecution said.
The examining magistrate finished his investigation in July last year, but defence lawyers said they would ask for an immediate adjournment at the opening hearing to give them more time to study the prosecution case.
Ines Harrath said her client, Achraf Sandi, was charged with "belonging to a terrorist group and using weapons," but was "neither a Salafist nor a terrorist.""
She said he had been arrested "because his brother, who is on the run, is accused of involvement in the case."
There has been widespread criticism of the Tunisian police force's response to the June 26, 2015 massacre.
British judge Nicholas Loraine-Smith, who held an inquest into the deaths of the Britons among the holidaymakers, said in February that the police response had been "at best shambolic, at worst cowardly".
"Their response could and should have been more effective," he said.
Andrew Ritchie, a lawyer representing 20 victims' families, read out a January 2015 report by a British diplomat, saying there had been "little in the way of effective security to prevent or respond to an attack" at the beach.
Nearly two years after the massacre, London still advises against non-essential travel to Tunisia, a restriction Tunis would like to see lifted.