The Tunisian gunman who allegedly shot dead 38 tourists at the resort town of Sousse crossed into Libya earlier this year to receive training, a media report said on Tuesday.
Six months before the attack, in January, 23-year-old Seifeddine Rezgui entered Libya, where he received training from a "a group of young extremists", Tunisian daily Echorouk claimed.
It is not known how long Rezgui, a 23-year-old electrical engineering student and jihadist sympathiser spent in Libya, but he subsequently stayed in the Tunisian capital, the daily said.
It was while he was in Tunis that Rezgui announced his support for the Islamic State (IS) radical group via social media and was put in touch with an IS sleeper cell in the capital, according to Echorouk.
IS, which had incited supporters worldwide to carry out attacks during Ramadan, claimed the Sousse beach attack, most of whose victims were British.
Tunisia has beefed up security since Friday's attacks at a beachfront hotel in Sousse, the worst in TunisiaÂ's history. Tunisia needed more assistance in securing its frontiers, especially with Libya, the country's President Beji Caid Essebsi said in an interview with Europe 1 radio on Tuesday.
The attacks have devastated the country's vital tourism sector and the tourism minister has predicted the industry will lose $500 million this year.