The trial of 17 people accused of Tunisia’s deadliest extremist attack has reopened.

A total of 38 people were killed in the Mediterranean resort of Sousse in 2015, 30 of them from Britain.

The judge read out a report detailing how attacker Seifeddine Rezgui walked on to the beach of the Imperial Hotel on June 26, 2015 and used an assault rifle to shoot at tourists in lounge chairs.

He then continued on to the hotel pool before throwing a grenade into the hotel.

Rezgui, a Tunisian student who trained with Libyan militants, was killed about 15 minutes later by police, the judge said.

Islamic State claimed responsibility for the attack.

Rezgui’s autopsy showed he was under the effects of an illegal drug as well as medications, according to the judge.

The trial had been postponed several times at lawyers’ request. It reopened Tuesday in Tunis, more than three and a half years after the attack.

All the defendants deny any direct role in the attack.

Rezgui shot at tourists on lounge chairs on the beach  Credit: Bircham Dyson Bell/PA

Some of the defendants face potential capital punishment for charges of premeditated murder, threatening state security and belonging to a terrorist-linked group.

Some of those who testified acknowledged ties to the man considered to have orchestrated the attack, Chamseddine Sandi, saying he asked them to case out the area ahead of time.

One said he sent Sandi photos via the internet of potential targets, including foreign businesses based in Tunis.

Defendant Mahmoud Kachouri said he was a classmate of Rezgui’s and they used to have coffee together.

He insisted “he never talked to me about the operation he was planning.”

The 17 on trial are among some 40 people overall suspected of involvement in the attack, according to defence lawyer Hanene Khemiri.

They include six security agents who are accused of failing to prevent or stop the attack.

The trial resumes on February 5.