Footage of those injured arriving at hospital was filmed and show many still in their swimsuits and covered in blood.

The slaughter happened when gunmen exchanged fire with security services on the busy beach, a popular destination for holidaymakers from the UK and Ireland.

The country's Health Ministry confirmed that those killed included Britons, Tunisians, Germans and Belgians. Thirty six others have been wounded.

A British holidaymaker staying in a hotel close to where the incident happened told Sky News: "The beach tends to be full up very quickly so it's the usual story of getting down to lay your towel at half past six to get a decent beach position, so all of the beach positions were taken.

"It's quite a busy beach."

"There's a lot of people walking up and down, taking in this lovely weather, so it's a very busy beach, but as I said it became apparent very quick that it was something more than firecrackers when you could hear bullets whizzing around."

The attackers rushed into the Imperial Marhaba hotel in the latest attack on the North African country's key tourism industry.

"A terrorist infiltrated the buildings from the back before opening fire on the residents of the hotel, including foreigners and Tunisians,"a government spokesman said.

Rafik Chelli, one of Tunisia's leading security officials, told Mosaique FM that the gunman who was shot by security forces was unknown to authorities.

He said the man, from the city of Kairouan, came from the beach hiding his Kalashnikov under an umbrella before opening fire on tourists. From there he entered the hotel through the pool, shooting people as he went.

Since overthrowing its secular dictator in 2011, Tunisia has been plagued by terror attacks, although they have only recently targeted the vital tourism sector.

In March, two gunmen attacked the national museum in Tunis killing at least 22 people, all but one of them tourists. A group pledging allegiance to the radical Islamic State group claimed that attack and promised more in Tunisia.

Tourism is a major part of the Tunisian economy, especially in coastal resorts like Sousse and it suffered in the aftermath of the 2011 revolution.

With a return to stability and new elections late last year it was slowly recovering, until the attack on the Bardo museum.

Spanish prime minister Mariano Rajoy confirmed that the Imperial Marhaba is owned by the Spanish company RIU.

The company's media office said RIU's board of directors was holding an emergency meeting following the attack. The firm also offered its condolences to the victims and their families.