Thousands of scared foreign tourists were being flown from Tunisia on Saturday after an Islamist gunman killed 39 people, most of them British, at a beach resort.
The Islamic State jihadist group, which controls swathes of Iraq and Syria, claimed responsibility for the attack, the deadliest in Tunisia's recent history.
Dozens more people were wounded when the assailant pulled a gun from inside a beach umbrella and opened fire on crowds of tourists on the beach and by a hotel pool in the popular Mediterranean resort of Port el Kantaoui.
'I saw someone get shot'
Witnesses described scenes of panic after the shooting at the hotel on the outskirts of Sousse, about 140 kilometres (90 miles) south of the capital Tunis.
"All I saw was a gun and an umbrella being dropped," British tourist Ellie Makin told ITV television.
"Then he started firing to the right-hand side of us. If he had fired to the left I don't know what would have happened, but we were very lucky."
Briton Olivia Leathley, 24, heard "loud bangs" and when she went to the lobby to find out what was happening, she saw a woman whose husband had "been shot in the stomach in front of her".
"All she said was that he'd been shot and that he was there bleeding on the beach and he was just saying, 'I love you, I love you', and then his eyes rolled back into his head."
Another woman described how her fiance was shot three times while trying to protect her and was in intensive care in hospital.
"I owe him my life because he threw himself in front of me when the shooting started," 26-year-old holidaymaker Saera Wilson told the BBC.
Riu Imperial Marhaba Hotel pastry cook Slim Brahim said that after mowing down tourists on the beach the gunman had then turned his weapon on guests by the hotel pool.
"I saw someone fire on elderly tourists. They were killed," Brahim told AFP. "Then he threw a grenade by the pool."
hotel event leader Omar Brik said, "I was looking after my group when I heard shots and then a burst of machinegun fire from the beach."
The 22-year-old employee said he saw the gunman, who authorities say was killed, walk towards the pool and "fire at the tourists".
"An older woman and her husband pleaded with him to spare them, to no avail. He shot them down without pity, in cold blood," said Omar, who could see from the second floor as the massacre unfolded.
Witnesses described scenes of panic as people fled, leaving behind sunglasses and other personal belongings.
One young man who witnessed the tragedy told police that the gunman fired only at tourists.
"The terrorist told us 'stay away, I didn't come for you'," he said.
"He did not fire at us -- he fired at the tourists."
Visibly shocked holidaymakers gathered in the reception area of the hotel which was also crowded with policemen, gendarmes and members of the anti-terrorist unit.
British tourist James Rouse said he was by the poolside when he heard machinegun fire.
He said he grabbed his daughter and took his mother by the arm and pulled them outside towards the exit.
Tunisian men help an injured woman in the resort town of Sousse. (AFP Photo)
Blow to tourism industry
Tunisian Prime Minister Habib Essid announced that from next month armed tourist security officers would be deployed all along the coast and inside hotels.
But a heavy blow had already been delivered to the key tourism industry with British tour operator Thomas Cook announcing it would offer all customers the possibility to change bookings to Tunisia up to and including July 24.
The Association of British Travel Agents said it was consulting with the foreign office about the longer term.
The Tunisian Prime Minister said that most of the dead were British but that they also included Germans, Belgians and French.
The attack, the second against tourists in Tunisia this year, came on the same day that 26 people were killed at a Shiite mosque in Kuwait and a suspected Islamist attacked a factory in France.
IS claimed both the Kuwait bombing and the Tunisia attack, which came just days before the first anniversary of the group declaring its territory in Iraq and Syria a "caliphate".
IS said the gunman was a "soldier of the caliphate" who had targeted enemies of the jihadist group and "dens (of...) fornication, vice and apostasy".Most of those killed were "subjects of states that make up the crusader alliance fighting the state of the caliphate", the group said, referring to the US-led coalition conducting an air campaign against it in Iraq and Syria.
Tourists comfort each other after the mass shooting in the resort town of Sousse, a popular tourist destination 140 kilometers (90 miles) south of the Tunisian capital. (AFP Photo)
Tunisian secretary of state for security Rafik Chelly told Mosaique FM the gunman was a student previously unknown to the authorities.
"He entered by the beach, dressed like someone who was going to swim, and he had a beach umbrella with his gun in it. Then when he came to the beach he used his weapon," Chelly said.
New security measures
The Tunisian premier said a raft of new anti-terrorism measures would go into effect from July 1, including the deployment of reserve troops to reinforce security at "sensitive sites... and places that could be targets of terrorist attacks".
He said the government would also close 80 mosques suspected of inciting extremism.
It constituted an "exceptional plan to better secure tourist and archaeological sites," he said.
But tour operators scambled to fly thousands of fearful holidaymakers home from Tunisia.
During the night, 13 aircraft took off from Enfidha airport north of Sousse.
Travel companies Thomson and First Choice said 10 Thomson Airways flights would be repatriating about 2,500 Thomson and First Choice customers on Saturday.
They said some of their customers had been caught up in the massacre.
The shooting followed a March attack claimed by IS on Tunis's Bardo National Museum that killed 21 foreign tourists and a policeman, and the tourism industry had already been bracing for a heavy blow.
Tourism accounts for seven percent of Tunisia's GDP and almost 400,000 direct and indirect jobs.
Read:39 killed in IS shooting: Tunisia beach resort turns horror house