LIMA, Dec 4 (Reuters) - A dramatic and deadly attack on a gold mine in Peru on Saturday has thrown a spotlight on illegal miners and criminal gangs targeting mines, which in recent years has left scores dead and cost billions of dollars in losses, according to industry and government officials.

Nine workers were killed and 10 others gravely injured in the latest attack where men armed with explosives raided and took hostages at a mine belonging to Poderosa, one of Peru's top gold producers. The government blamed illegal miners and criminal groups.

The attack has highlighted a growing risk for miners in the Andean nation, the world's no. 2 copper producer and an important source of gold and silver.

"Security is now one of the main costs," Poderosa corporate affairs manager Pablo de la Flor told Reuters after the attack. "Illegal miners and criminal groups represent a terrible alliance for the sector."

Attacks on Poderosa last year left seven dead and 10 transmission towers destroyed. In another event not involving Poderosa in June last year, a confrontation between artisanal gold miners over land in southern Peru left 14 dead.

The impact is showing up on balance sheets, a headache for firms and Peru's government as it battles to dig out of a recession, with mining the country's main economic engine.

A recent study by local industry chamber the National Society of Mining, Petroleum and Energy of Peru (SNMPE) said that illegal gold mining is responsible for about $6 billion in annual losses, some 2.5% of domestic GDP.

Poderosa itself has seen its profits and production hit this year as operating costs have risen by a third, according to a corporate filing, which it blamed on higher "security and surveillance costs".

The mining firm was the largest gold producer in Peru in the last two years, responsible for 10% of production, though it has fallen to second place in the first nine months of 2023.

De la Flor said Saturday's attack would not stop the company's operations.

BIGGER THAN DRUG TRAFFICKING

Illegal mining in Peru moves more money than drug trafficking, between $3 billion and $4 billion per year, according to government data.

De la Flor says illegal mining has grown thanks to a program designed to formalize artisanal miners, called REINFO, that provides temporary licenses to small mines.

"It is the umbrella under which they protect themselves, because having a REINFO prevents the police from intervening in illegal mines," he said.

The executive said initially artisanal miners hired "criminal gangs" to protect their operations but the groups then took over operations when they saw it was profitable.

Peru's Ministry of Energy and Mining did not immediately respond to a request for comment on the issue. The ministry released a statement on Sunday night saying it would take a look at REINFO to identify those taking advantage of the program.

Poderosa said earlier this year its mine in the province of Pataz had "been invaded by Peruvian and foreign criminals allied to illegal miners" with the aim of controlling its operations. Thousands of trucks of illegal gold were taken out, it said.

While the main destinations for Peruvian gold are India, Switzerland and Canada, which account for nearly two-thirds of the country's exports, experts say black market gold has been flooding into nearby Bolivia.

"There is a black market for minerals," said Gustavo Ramirez, who studies illegal mining for SNMPE. "It is not that difficult to assume that the gold is Peruvian and that it leaves through the border."

Peru's gold output, which has fallen for a decade due to a lack of new operations, rose to 97 metric tons last year, according to Ministry of Energy and Mines. Illegal miners are estimated to produce around another 30 tons. (Reporting by Marco Aquino Report; Writing by Alexander Villegas Editing by Marguerita Choy)