Tunisia's prime minister on Saturday called for all citizens to work together to defeat terrorism as thousands of tourists prepared to leave the North African country in wake of its worst terrorist attack ever.

Tourists crowded into the airport at Hammamet near the coastal city of Sousse where a young man dressed in shorts on Friday pulled an assault rifle out of his beach umbrella and killed 39 people, mostly tourists.

"The fight against terrorism is a national responsibility," said a visibly exhausted Habib Essid at a press conference in Tunis early Saturday. "We are at war against terrorism which represents a serious danger to national unity during this delicate period that the nation is going through."

He announced a string of tough measures to fight extremism, including examining the funding of organizations suspected of promoting radicalism, closing some 80 mosques outside government control and declaring certain mountainous zones military areas.

He identified the shooter, who was killed by police after the attack, as Seifeddine Rezgui, a young student at Kairouan University. A tweet from the Islamic State group claimed responsibility for the attack and gave his jihadi pseudonym of Abu Yahya al-Qayrawani, according to the SITE intelligence group.

At the Imperial Marhaba Hotel where the attack took place, vans and buses were carrying away tourists on Saturday. While the hotel was not actually closing down, the tour operators had urged everyone to leave, the director said.

"We may have zero clients today but we will keep our staff," said Mohammed Becheur, adding the 370-room hotel had been at 75 percent occupancy before the attack.

Tourism is a key part of Tunisia's economy and had already fallen some 25 percent after a terrorist attack on the national museum in the capital Tunis that killed 22 people in March.

"It's really sad but what can you do, for everyone, for the tourists, for the people who died, for their families," said Belgian tourist Clause Besser, as he recovered in the hospital from a gunshot wound he received fleeing from the attacker. "For me, somehow, with a bullet in the leg, it's not a catastrophe. For those who died or were injured for life, it's something else."

British travel companies Thomson and First Choice said they are flying back thousands of tourists from Tunisia Saturday and are cancelling all flights to the country in the coming week. Tourist flights from Ireland to Tunisia have continued in the wake of the attack, but travel agents are offering full refunds for those canceling.Slovakia has sent a plane to evacuate some 150 of its citizens who are currently in Tunisia, according to the Foreign Ministry and Scandinavian tour operators have stopped all flights to the North African country for the rest of the season.

"We felt a bit scared because Sousse isn't that far away, it's only 40-50 kilometers (25-30 miles) from where we stayed," said Kathrin Scheider as she waited in line to check in to her flight out of the country at the Hammamet airport near Sousse. "We felt quite safe during the whole holiday, but as soon as we heard, we were quite happy to leave because you don't feel that safe anymore if something happens like that."

The Tunisian Ministry of Health has confirmed the nationalities of 10 of the 39 victims of the attack, including eight Britons, a Belgian and a German. The government of Ireland said an Irish nurse was also among those who were killed.

Relatives and family friends say Lorna Carty was fatally shot as she sunbathed. She and her husband, Declan, had received the holiday as a present to help Declan Carty relax following his recent heart surgery. Family friends speaking to the couple's two children said Lorna Carty went ahead of her husband to the beach, where she suffered fatal gunshot wounds and was pronounced dead in hospital.

___

Bouazza reported from Tunis, Tunisia. Associated Press reporters Shawn Pogatchnik in Dublin and Benjamin Wiacek in Sousse contributed to this report.