Updated

Panicked tourists fled from a popular beach in Tunisia Friday as a gunman pulled an automatic rifle from under an umbrella and began shooting, killing 37 people, officials said.

The attacker, who was dressed in shorts, came from the beach hiding his Kalashnikov gun before spraying terrified tourists with bullets. People were told to run in a chaotic scene near a beach in Sousse, and many took refuge in hotel rooms after the gunfire erupted, Sky News said.

Tunisia's Interior Ministry originally said there were two gunmen but later said they believed just one gunman acted alone, killing 37 people and wounding at least 36. The Health Ministry said the dead include Tunisians, Brits, Germans and Belgians.

The gunman reportedly entered the Hotel Imperial through the swimming pool area, shooting people as he went. He also threw an explosive, witnesses said.

The suspect—who was not identified-- was killed by police in a shootout.

More On This...

    "He was certainly involved with certain extremists," said Chelli, the secretary of state of the Interior Ministry

    British tourist Gary Pine said he was on the beach and heard what "we thought was firecrackers going off" 100 yards away, followed by an explosion from the next hotel complex along.

    "There was a mass exodus off the beach," he told Sky News. He said his son said he had seen someone get shot on the beach. Guests at his hotel were first told to lock themselves in their rooms, and later to gather in the lobby, Pine said.

    Photographs seen by Sky News show one elderly man lying in a pool of blood in his swimming shorts.

    Tunisian officials identified the hotel Rajoy referred to as the Hotel Riu Imperial Marhaba in the Port El Kantaoui neighborhood of Sousse. It is owned by Spain's RIU Hotels & Resorts, which has more than 100 hotels in 19 countries.

    Spanish Prime Minister Mariano Rajoy confirmed a Spanish company owned one of the two beachside tourist hotels. Rajoy said from Brussels that the attacks Friday in Tunisia and at a factory in France were both acts of terror.

    A terror expert says they should "probably be seen as an attempt to destabilize the economy as well as the wider political situation in Tunisia."

    Alexander Meleagrou-Hitchins from the International Centre for the Study of Radicalization at King's College London said similar attacks had earlier damaged tourism in Egypt and Kenya. He said Friday's attack is "really is going to lead to a massive reduction in tourism."

    "We have people relaxing on the beach on their holidays being murdered -- that is not going to help the attempts by the Tunisian tourist industry to get people to come to the country," he said.

    Sousse, some 90 miles from Tunis, is a popular resort for both Tunisians and Europeans.

    Tunisia has been battered by attacks by militants, most recently in March when two Tunisians returning from Libya killed 22 people at the national museum.

    The Associated Press contributed to this report.