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.
Tunisian Prime Minister Habib Essid announced that from next month armed tourist security officers would be deployed all along the coast and inside hotels.
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.
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.
Travel companies Thomson and First Choice said 10 Thomson Airways flights would be repatriating about 2,500 Thomson and First Choice customers today.
They said some of their customers had been caught up in the massacre.
