At least 39 people, mostly foreigners, have been killed and 36 injured in an attack on a beach in the Tunisian resort town of Sousse, officials say.
Video footage showed the body of a suspected gunman lying in a street.
Tunisians, Britons, Germans, Belgians, French and at least one Irish citizen are among the dead in the attack claimed by Islamic State (IS).
In March militants killed 22 people, mainly foreign tourists, in an attack on a museum in the capital Tunis.
Islamic State said it was behind Friday's attack. It had urged followers to step up assaults during Ramadan.
Social media accounts close to IS showed pictures of the man they say carried out the killings.
Day of attacks
The shooting in Tunisia comes on the same day as:
Tunisian Prime Minister Habib Essid said "the majority" of victims were British, without providing details.
Earlier, UK Foreign Secretary Philip Hammond said at least five Britons were confirmed dead, adding: "We must expect more reports of fatalities".
Tunisian President Beji Caid Essebsi - who visited some of the wounded in hospital - has promised "painful but necessary measures" in the wake of the attack.
At the scene: BBC's Rana Jawad
This was a brazen attack that has affected everyone here.
Tourists gathered in the hotel lobby of the Marhaba Imperial consoling each other. Most were thankful they had survived and described a day where they faced their worst fears: not seeing their children again back home or losing a loved one before their eyes.
A woman sat in alone in a corner silently crying with her packed luggage sitting beside her. So many here were frustrated at having to stay at the scene of the attack tonight, but one busload after another took many of the residents away.
These are sobering times for a country, and people now reeling from the effects of deadly attacks on tourists.
But the people of Sousse remain defiant: they are socialising with friends and family, and large parts of the city are still lit up on what is arguably its darkest day yet.
Security officials said a attacker had posed as a swimmer but was carrying a rifle under a parasol. He started shooting on the beach before entering the Hotel Riu Imperial Marhaba, continuing to shoot as he walked past the pool.
He was then shot dead in an exchange of fire with police, officials said. They said he was a student not previously known to authorities.
Local media reported that a second suspected attacker had been arrested, but this has not been confirmed.
One British holidaymaker in Sousse, Steve Johnson, told the BBC: "We were just lying on the beach as usual and... we heard what we thought at first was fireworks.
"But it was soon pretty obvious... that it was firearms that were being discharged and people screaming and starting to run."
'He took a bullet for me'
One survivor told the BBC how her fiance, a Welsh tourist, had been shot three times as he used his body as a shield.
"He took a bullet for me," said Saera Wilson. "I owe him my life because he threw himself in front of me when the shooting started.
"It was the bravest thing I've ever known. But I just had to leave him under the sunbed because the shooting just kept on coming.
"I ran back, past bodies on the beach to reach our hotel. It was chaos - there was a body in the hotel pool and it was just full of blood.
The UK Foreign Office said the British embassy in Tunis was sending a crisis team to the area.
"Any British nationals in these hotels or nearby should remain indoors, and contact their tour operator and the Foreign Office," the FCO said in its updated travel advice.
The Belgian foreign ministry is advising against all travel to Tunisia and the Belgian Jetairfly airline recalled a flight en route to Tunisia in mid-air, later announcing it is cancelling all flights to Tunisia because of the attack.
Friday's attack was the deadliest in Tunisia's recent history. The country has seen militant Islamists gain strength since the overthrow of long-serving ruler Zine al-Abidine Ben Ali in a popular uprising in 2011.
Democratic elections after Ben Ali's removal saw the moderate Islamist Ennahda party take power before the secularist Nidaa Tounes government won a parliamentary poll in October.
However, neither party has been able effectively to combat Islamist violence made worse by a raging conflict in neighbouring Libya and by Tunisian fighters returning home after going to join Islamist campaigns in Iraq and Syria.