Tunisia attack: What happened
Thirty-eight people lost their lives when a gunman opened fire on tourists staying in the popular resort of Port El Kantaoui, just north of Sousse in Tunisia on 26 June 2015.
Thirty of those killed were British tourists staying at the Hotel Rui Imperial Marhaba. Three people from Ireland, two Germans, one Russian, a Belgian and Portuguese woman also died.
So-called Islamic State (IS) said it was behind the attack by Tunisian student Seifeddine Rezgui.
Gunman arrives: approx 11:15 local time (10:15 GMT)
The attacker arrived in Sousse by van and was dropped off down a side road, a short distance from the beach.
CCTV images show Rezgui making his way along the beach, carrying a long object over his shoulder, which later turned out to be a Kalashnikov hidden in a parasol.
When he arrived at the five-star Hotel Rui Imperial Marhaba, he opened fire indiscriminately at tourists on sunloungers on the beach.
The inquest into the deaths of the 30 British victims heard from one of the hotel guests, John Graham, who together with his wife, Eva, had arrived on the beach at about 11:00 that morning.
His statement made shortly after the attack was read to the court. In it he said he had a clear view of the gunman: "He was firing indiscriminately. He started firing, he raked to the right, raked to the left, grabs the gun with both hands and then aims it at the front row."
A former police chief superintendent, Michael Perry, told the coroner he initially thought the gunshots were fire crackers, but quickly realised they were under attack.
As holidaymakers fled for their lives, the gunman continued his attack, entering the hotel complex via the pool area.
Gunman enters hotel
Kevin Hawkes was on holiday with his wife, Marilyn. He had served with the army for 22 years and worked as a weapons instructor.
He described how he helped his wife escape back to their room and then went back to try to help an injured man.
As he reached the reception area he said he heard "an almighty bang" and looked up to see a big glass table had shattered and a glass panel with a bullet hole in it.
He said: "I just lay there. I was thinking that he would come for me. It felt like I had been there for a lifetime."
Carly Lovett, 24, and her fiance Liam Moore also ran into the hotel when they heard shooting on the beach, hiding in a staff area behind reception.
Mr Moore said there was a massive bang and when the smoke cleared he saw Ms Lovett lying on the floor. She had an injury to her arm and there was a lot of blood.
He said he tried to stop the bleeding and tried to resuscitate her, before realising she had died. Although Ms Lovett had been injured by the explosion, she died from a gunshot wound to the chest.
Gunman flees scene
The gunman then escaped back out to the beach, where he was filmed running past the neighbouring Hotel Riu Bellevue and up a side alley, still armed with his gun and he is reported to have been carrying a grenade.
A hotel worker also filmed his own pursuit of Rezgui from the hotel complex, along the beach and out onto the street.
Gunman shot: approx 12:30 local time (11:30 GMT)
After the gunman fled the beach, local builder Mayel Moncef spotted Rezgui from his rooftop vantage point and hurled a pile of tiles down on his head.
He said Rezgui began firing wildly in the street, at which point the police returned fire and shot him. Mr Moncef said he spotted a grenade roll from the attacker's hand as he fell.
Ajmi Boubakir, who runs a souvenir shop in the same street, described how he gave shelter to a crowd of about 35 tourists who were fleeing the gunman.
After staying inside for more than an hour, Mr Boubakir looked outside to discover security forces heavily deployed and the gunman laying dead in the street.
He "was shot 20m (66ft) away from my shop, right there," he said, indicating the end of the alleyway.
Mr Boubakir's car, which was parked in front of the shop, was caught in the crossfire and his building's wall also bore the scars of bullets.
Who was the gunman?
Rezgui was a student of electronics and not previously known to the security service. However, Islamic State (IS), which admitted carrying out the attack, referred to him by a nom de guerre - Abu Yahya al-Qayrawani.
He was from the town of Gaafour in Tunisia's interior and had studied in the city of Kairouan.
Rezgui is believed to have worked with gang who attacked the Bardo National Museum three months before the Sousse attack and trained alongside one of the gunmen at an IS camp in Libya
A BBC Panorama investigation revealed Chamseddine al-Sandi was named as the "mastermind" behind the attacks, paying for the attackers to go to Libya and giving them their orders.
Al-Sandi is now believed to be on the run in Libya.