The attack took place at the Hotel Imperial Marhaba in Sousse, a popular resort town on the northeast coast of Africa.
The gunman, who acted alone, was killed by police after the attack, the country's Interior Ministry told the Associated Press. The gunman was not known to authorities, security official Rafik Chelli told Tunisia radio station Mosaique FM.
ISIS claimed responsibility for the attack in a statement circulated on social media today.
Chelli said the gunman hid his Kalashnikov rifle under an umbrella before he opened fire. The gunman then entered the Hotel Imperial through the pool and shot at people, Chelli told Mosaique FM.
Sousse is one of Tunisia's most popular vacation spots and draws visitors from across Europe -– particularly France. The nationalities of the victims are still being determined, officials said, but a security official confirmed to Mosaique FM that many victims were foreigners. At least five victims were British, according to the U.K. Foreign Office.
The hotel had 565 guests at the time of the attack, mostly from the United Kingdom and central Europe, RIU Hotels & Resorts said in a statement on its website, but the hotel has not confirmed nationalities of the victims.
RIU Hotels said 9 of its guests and 4 of its employees were hospitalized, all with non-life-threatening injuries.
A woman staying in an adjacent hotel told Irish radio program RTÉ Radio: "As I was running towards the hotel, the waiters and security on the beach started saying, 'Run, run, run.' And we just ran to our room."
Tunisia has been on high-alert since March, when Islamist militant gunmen attacked a museum, killing 22 foreign tourists.
The attack in Tunisia is one of three alleged terrorist attacks today: in Kuwait, at least 16 were killed in an attack on a Shiite mosque, and in France, a man was believed to have been decapitated at an American-owned energy factory.
The White House said in a statement: "The United States condemns in the strongest terms the terrorist attacks in France, Kuwait, and Tunisia today. Our thoughts and prayers are with the victims of these heinous attacks, their loved ones, and the people of all three countries. As the President has discussed with his French, Kuwaiti, and Tunisian counterparts in recent weeks, we are resolute and united in our shared effort to fight the scourge of terrorism.
We stand with these nations as they respond to attacks on their soil today, and we have been in contact with appropriate counterparts in all three countries to offer any necessary support. Terrorism has no place in any society, and the United States will continue to work closely with our international partners to combat terrorist actors and counter violent extremism around the globe."