Tunisia’s Prime Minister Habib Essid said most of the dead were British, and Britain’s foreign office said 15 Britons had been confirmed killed in the attack in the resort town of Sousse, 140 km (90 miles) south of the capital Tunis.
A German, a Belgian and an Irish woman have also been identified, foreign and Tunisian officials said.
It was the second major attack in the North African country this year, following an Islamist militant assault on the Bardo Museum in Tunis in March when gunmen killed a group of foreign visitors as they arrived by bus.
Tunisia has undergone a largely peaceful transition to democracy since its 2011 Arab Spring uprising, but its army has been fighting a rise in Islamist militancy.
Tunisia’s tourism minister called Friday’s attack in one of the country’s most popular resorts for Europeans a “catastrophe” and authorities vowed to toughen security, drafting in army reserves and arming tourism police at beaches and hotels.
Saloua Kadri, Sousse tourism commissioner, said more than 3,000 foreign tourists had fled the town on Saturday, including around 2,200 British and nearly 600 Belgians.
Dozens of tourists were waiting to take flights out from the nearby Ennfida airport.
“We don’t want to stay any longer, we just want to see our family, parents … so leaving as soon as possible,” said Hannah Russel, an British tourist.
Sarah Maeson, another Briton flying back to Manchester, said: “We don’t feel safe. Constantly hearing sirens and helicopters is not really helping your nerves.”
Tunisian authorities named the gunman as Saif Rezgui, a student who they say was not known to them. Dressed in shorts and T-shirt, Rezgui opened fire on the beach of the Imperial Marhaba hotel on Friday, picking out foreigners and leaving Tunisians alive.
Witnesses said he made his way to the pool and hotel, his killing spree ending only when he was shot dead by police.
Tour operators Thomson and First Choice, which are owned by German travel group TUI, said they had about 6,400 customers across Tunisia at the time of the attack, including several of the people killed and injured.
They sent 10 planes to evacuate tourists and said 1,000 had already been repatriated. They also said they would cancel all their holiday packages to Tunisia for at least the next week.
TUI’s German tour operator TUI also organized flights for tourists wishing to return home and TUI’s Belgian airline, Jetairfly, sent six empty planes to bring tourists back from the island of Djerba and from Ennfida airport on Saturday.
German Foreign Minister Frank-Walter Steinmeier confirmed one German had been killed, but said there may be others.
Tobias Ellwood, a junior minister at Britain’s foreign office, told reporters in London the British death toll could rise as there were several who had been seriously wounded.
“This is the most significant terrorist attack on British people since 7/7,” he said, referring to attacks on the London transport system on July 7, 2005, that killed 52 people.
NOT ON WATCHLIST
Tunisian authorities said the gunman was not on any watchlist of known potential militants. But one source said Rezgui appeared to have been radicalized over the last six months by Islamist militant recruiters.
As one countermeasure, Prime Minister Essid said that Tunisia planned within a week to close down 80 mosques that remain outside state control for inciting violence.
Several thousand Tunisian jihadists have gone to fight in Syria, Iraq and neighboring Libya, where some have set up training camps and vowed to return to attack their homeland.
The attack took place during the holy Muslim month of Ramadan and was one of three linked to Islamist militants on three different continents on Friday.
In France, a decapitated body daubed with Arabic writing was found, and in Kuwait a suicide bomber killed two dozen people at a mosque in Kuwait.