By Tarek Amara

TUNIS (Reuters) - The Tunisian gunman who carried out a deadly attack on a hotel last Friday trained in a jihadist camp in Libya last year, Tunisia's government said on Tuesday.

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.

A spokesman for the prime minister said Saif Rezgui, who was killed by police following the rampage, was in Libya at the same time as two Tunisian gunmen who subsequently stormed the Tunis Bardo museum in March.

The museum assault killed 21 people. The twin attacks have dealt a brutal blow to the country's vital tourism industry.

Authorities have arrested three others for allegedly helping to plan Rezgui's attack, a security source said.

"Rezgui had training in Libya at the end of 2014. He was trained during the same time in Libya as the Bardo attackers," prime ministerial spokesman Dafer Neji told Reuters.

Libya, caught in a multi-sided battle between two rival governments and their armed factions, has become a focus 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 clandestinely crossed into Libya for training late last year, investigators have said. Rezgui had taken out his passport last year, but there were no exit stamps in it, officials said.

Initial local radio reports on Friday had suggested there may have been another gunman. However, Tunisian security sources say forensic evidence showed all victims were shot by the gun used by Rezgui, indicating he was alone.

Britain's Daily Mirror newspaper quoted five British holidaymakers who said they had seen a second attacker, whom two described as having worn different colored shorts to Rezgui.

Tunisia's health ministry said on Tuesday it had so far identified 33 bodies from Friday's violence, including 25 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 transitioned to democracy after a 2011 uprising.

HUGE LOSSES

Tunisia expects to lose at least $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.

(Writing by Patrick Markey; Editing by Sophie Walker and Crispian Balmer)