The Tunisian gunman who attacked a resort hotel on Friday killing 39 people, mostly British holiday-makers, likely spent time in a training camp in Libya and had been in contact with militants over the border, a security source said on Tuesday.
The attack on the Imperial Marhaba beach hotel in the popular resort town of Sousse came just months after militants attacked the Bardo museum in Tunis, killing 21 people and delivering a blow to the vital tourism industry.
Investigators were verifying whether the gunman, student Saif Rezgui, had received militant training in a jihadist camp across in Libya. Authorities have also arrested three others for helping to plan the attack, a security source said.
"Investigations show Saif Rezgui was in contact with terrorists in Libya and he likely trained in a Libyan camp," an official source told Reuters.
Libya, caught in a multi-sided battle between two rival governments and their armed factions, has become a target for Islamic State supporters and other jihadist groups who have taken advantage of the security chaos.
The two gunmen who carried out the March attack on the Bardo had also clandestinely crossed into Libya for training late last year, investigators said. Rezgui had taken out his passport last year, but there were no exit stamps in it, officials said.
The Sousse attacker, who had shown little sign of radicalization by fundamentalist Islamist recruiters, was shot dead by police outside the hotel.
Tunisia's health ministry said on Tuesday it had so far identified 27 bodies from Friday's gun attack, including 19 British, three Irish, one Belgian, two German, a Russian citizen and a Portuguese national.
The massacre was the worst of its kind in Tunisia, one of the Arab world's most secular countries, which has been praised for its transition to democracy after a 2011 uprising.
Tunisia expects to lose at least US$515 million this year, or about a quarter of its estimated annual tourism earnings, following last Friday's attack.
"The attack had a great impact on the economy, the losses will be large," Tourism Minister Salma Loumi told reporters late on Monday, giving a preliminary estimate from the Sousse attack.
The North African country earned $1.95 billion in revenues from tourism last year. The sector makes up seven percent of its gross domestic product and is a major source of foreign currency and employment for Tunisia.
Loumi said the government planned to end a visitors' tax and also to review debt relief for hotel operators as ways to help sustain the industry.
The government has said 1,000 more armed tourism police will patrol hotels and tourism sites and the army reserves will also be drafted in to beef up protection.
Praised for its new constitution, free elections and politics of compromise after the 2011 uprising to oust autocrat Zine El-Abidine Ben Ali, Tunisia has also struggled with the rise of fundamentalist Islamist movements that flourished in the early turmoil.
Some of those groups turned to violence and Tunisia's armed forces have been fighting occasional skirmishes with local Islamist militants near the border with Algeria.
But more than 3,000 Tunisians have also left to fight for militant Islamist groups in Syria, Iraq and Libya, and some have threatened to return to carry out attacks in their homeland.