Several people were injured in the attack
Officials say one gunman has been shot dead and another is being pursued.
Interior Ministry officials said Tunisians, Britons, Germans and Belgians are among the dead.
In March militants killed 22 people, mainly foreign tourists, in an attack on a museum in the capital Tunis.
Tunisian President Beji Caid Essebsi has gone to Sousse?s Sahloul hospital to visit the injured.
Security officials said one attacker, who had posed as a swimmer but was carrying a rifle under a parasol, was shot dead in an exchange of fire with police.
Local media reported that the second attacker had been arrested, but this has not been confirmed. A photo purporting to show the body of the first attacker is circulating on social media.
One of the victims is reported to have been an Irish woman.
A British man on holiday told the BBC that he heard the attack on a neighbouring hotel.
From his room, he saw a man with a pistol but did not know whether this was an attacker or a member of the security forces.
The Hotel Imperial Marhaba was named as one of the hotels close to the attack.
Briton Glenn Leathley told the BBC his daughter had been at the scene and rang him to say ?there?s gunfire on the beach?.
Another British holidaymaker, Steve Johnson, told the BBC: ?We were just laying 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.?
One image circulating on social media appeared to show a man lying face down in the sand with what looks like blood around his head.
The Islamic State militant group had called on its followers to increase attacks during the Islamic fasting month of Ramadan, but no-one has yet said they were behind this attack.
The Belgian Jetairfly airline has announced it is cancelling all flights to Tunisia because of the attack.
A spokeswoman for the Thomson and First Choice tour operators said: ?We are working closely with our teams in Tunisia and the relevant authorities to determine exactly what has happened and provide assistance to those affected.?
Tunisia 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.