Tunisia, already destabilised by a political crisis, suffered a blow to its vital tourism industry after a suicide bombing and another that was foiled in two coastal resort towns.
Only the suicide bomber was killed Wednesday in an attack on a beachside hotel in Sousse, and the security forces thwarted another attempted suicide attack soon after in neighbouring Monastir.
The interior ministry said its special forces arrested five Salafist "terrorists" directly linked to the first suicide bids in the North African country for more than a decade.
It said those behind the attacks belonged to Ansar al-Sharia, Tunisia's main Salafist movement, which the authorities have designated a "terrorist organisation" with ties to Al-Qaeda.
The presidency insisted the attacks, which have yet to be claimed, would not "derail" the democratic transition.
It was referring to a national dialogue underway between the ruling Islamist party Ennahda and the opposition to end months of political crisis, sparked by the July assassination of opposition politician Mohamed Brahmi by suspected jihadists.
As part of a roadmap agreed by political leaders to break the political stalemate, Ennahda is to be replaced and a new prime minister named.
Ennahda's veteran leader Rached Ghannouchi, who has been criticised in the past for encouraging dialogue with hardline Salafists, denounced "those who tried to target tourists," calling them "criminals who want to destroy Tunisia, its economy and its democratic transition".
In the first attack, the suicide bomber "blew himself up on a beach in Sousse" near the four-star Riadh Palms hotel, interior ministry spokesman Mohamed Ali Laroui told AFP. There were no other casualties.
The bomber tried to enter the hotel by a back door but was spotted by guards and chased away before blowing himself up on the nearby beach that was deserted, witnesses said.
A spontaneous protest broke out in the centre of Sousse "to condemn terrorism," they added.
Within half an hour, security forces foiled another suicide attack by an 18-year-old man on the tomb of former president Habib Bourguiba, in Monastir, 20 kilometres (12 miles) along the coast.
Residents said they saw the would-be attacker behaving suspiciously in a cemetery near the tomb and reported him. He was arrested by presidential security guards.
Private radio station Mosaique FM identified the suspect as Aymen Saadi Berchid and said four arrest warrants had previously been issued for him.
Last year a Salafist was jailed for eight months for desecrating the tomb, a lavish building with two minarets and a gold dome that was commissioned by Bourguiba himself, Tunisia's staunchly-secular first president.
Since the 2011 revolution that toppled Zine El Abidine Ben Ali, Tunisia has been rocked by violence blamed on radical Islamists suppressed under the former dictator, including the killings this year of two opposition MPs.
But Wednesday's failed suicide bombings are the first in Tunisia since 2002, when an attack claimed by Al-Qaeda killed 21 people at the ancient Ghriba synagogue on the resort island of Djerba.
The attacks are likely to fuel fears for the stricken tourist sector, which has been largely untouched by the surge in jihadist violence since Ben Ali's ouster and which generates vital revenues for the cash-strapped government.
Extra security was meanwhile deployed at hotels in Tunis amid fears of another attack.
One newspaper said the attacks meant "terrorism is now targeting tourism".
"The target now is the beating heart of the Tunisian economy," read the editorial in the Une le Temps daily.
Mohamed Ali Toumi, the head of a Tunisian travel agents' federation, called for hoteliers to be "vigilant" as his organisation offered support to any guests who might have suffered trauma.
"Thank God there were no casualties, but hotel guests need psychological support," TAP news agency quoted him as saying.
The French embassy also urged "increased vigilance," and advised its citizens to avoid meeting places, while German Foreign Minister Guido Westerwelle assured his Tunisian counterpart Othman Jarandi of Berlin's continued support for the transition process.
Ennahda, which swept Tunisia's first post-revolutionary elections in October 2011, has been sharply criticised by the opposition for failing to combat a rise in jihadist militancy.
The government has linked Tunisia's armed jihadists to Al-Qaeda in the Islamic Maghreb, but it has admitted lacking adequate resources to combat them.