The Tunisian gunman who carried out a deadly attack on a hotel last Friday trained in an armed group's camp in Libya last year, Tunisia's government has said.
Officials said on Tuesday that Saif Rezgui, who was killed by police following the rampage, was in Libya at the same time as two Tunisians who stormed the Tunis Bardo museum in March, killing 21 people.
The death toll from the assault on the Imperial Marhaba beach hotel in the popular resort town of Sousse was revised down on Tuesday to 38 from a previously given 39. Most of the victims were British tourists.
RELATED OPINION: France, Kuwait, Tunisia: Where next?
Authorities have arrested three others for allegedly helping to plan Rezgui's attack, a security source told the Reuters news agency.
"It has been confirmed that the attacker trained in Libya with weapons at the same period as the Bardo attackers," said Rafik Chelli, the secretary of state for the interior ministry. "He crossed the borders secretly."
Chelli said Rezgui, a 24-year-old who obtained a master's degree in electrical engineering, left his studies and sneaked into the western Libyan town of Sabratha in January - when the two young men who carried out the museum attack in Tunis were there.
The spokesman for the interior ministry, Mohamed Ali Aroui, said it was not immediately clear whether Rezgui trained in the same group as the Bardo attackers.
Libya is caught up in a battle between two rival governments and has become a haven of armed groups, some pledging allegiance to the Islamic State of Iraq and the Levant (ISIL).
Initial local radio reports on Friday had suggested there may have been another gunman. However, Tunisian security sources said forensic evidence showed all victims were shot by the gun used by Rezgui, indicating he was alone.
Tunisia expects to lose at least $515m this year, or about a quarter of its estimated annual tourism earnings, following last Friday's attack.
Armed tourist police are to be stationed at hotels and army reservists called up in a bid to stanch the damage to the vital industry.