FOR centuries mining has formed the economic backbone of several Andean countries. It provides vital foreign exchange—40% of Chile's export income last year and half of Peru's. But it is a capital-intensive business. In Chile, it employs only 74,000 people; in Peru, miners form a mere 1% of the labour force. To its critics, mining leaves little behind except some big, and often polluted, holes in the ground.

In the recent past, both Chile and Peru were desperate to attract mining investment to revive their economies. Chile's investment law of 1974 was decreed by the dictatorship of General Augusto Pinochet and remains little changed. It grants tax stability for at least ten years for any new venture. Many mining companies in Peru signed similar deals with the authoritarian government of Alberto Fujimori.

Now, with world prices for minerals close to their highest levels in a decade, democratic politicians in both countries want mining companies to pay more tax. In early June, Peru's Congress approved (by 90 votes to 11) a law to levy royalties of up to 3% on sales of mineral concentrates. Chile's government announced in April that it was about to send to Congress a similar measure. But no bill has yet emerged: government lawyers are trying to find ways to ensure that it will survive the scrutiny of the Constitutional Court.

Neither government is enthusiastic about royalties, but in both countries they make for good politics. In Peru, the weak government of Alejandro Toledo reluctantly promulgated the law a fortnight ago. That prompted several of the industry's biggest names, including Anglo American and Southern Peru Copper Corporation, to pull out of an auction due on July 23rd for the right to develop Las Bambas, a huge copper deposit in southern Peru.

Mining bosses complain that “tax stability” is being torn up. In a memo, Jean Paul Luksic, the chief executive of Antofagasta, a London-registered mining firm, argues that the Chilean proposal “runs contrary to the letter and spirit” of existing mining concessions. The bill “would call into question the strong reputation which Chile has established as...the most stable and reliable investment destination in Latin America.” He adds that mining firms continued to invest when prices were low and should not be penalised now.

Supporters of the measures put forward two main counter-arguments. First, there is a strong case in principle for governments to charge royalties on mineral extraction, as Eduardo Engel, a Chilean economist at Yale University, points out. Mining companies are depleting a non-renewable resource. In most cases, their profits include “economic rents”, as economists call payments made to those who control resources whose supply, in the short term, does not vary with their price. On grounds of fairness, governments usually seek to share out those rents by taxing them. Some Canadian provinces, American states and Australia already levy royalties on mining.

Second, in Chile in particular, many mining companies pay almost no tax, because the law allows big write-offs for “accelerated depreciation” and other loopholes. Chileans were scandalised in 2002 when Exxon Mobil, an American firm, sold Disputada de las Condes, a copper company, to Anglo American for $1.3 billion; for the previous quarter-century Disputada had reported losses, so Exxon paid virtually no tax. Antofagasta made pre-tax profits of $357.2m in 2003 and $176.8m in 2002. Its bill for corporation tax was $58.9m in 2003 and $28.3m in 2002, yet its accounts state that tax paid was only $9.6m and $3.2m respectively.

But even if royalties are justified in principle, the devil is in the detail. Of the two bills, Peru's is the clumsier. By taxing sales of concentrates, it takes no account of the price cycle: firms will have to pay even when they are making losses. Some would escape royalties, either because they produce unprocessed ore (rather than concentrates) or because they have signed agreements that prohibit tax changes. But others might have to pay twice: the Las Bambas deposit is to be awarded to whichever firm offers the highest royalty above 2%; under the new law, the winner will have to pay a further 3% on top. Peru's government has sent a new bill to Congress that would rectify these problems.

Chile's draft bill avoids these pitfalls. It would levy royalties (of up to 3%) only on firms with operating margins of over 5%. For the first three years, this would take the form of a credit against corporation tax. Officials say this means that the royalties will apply only to new investments, not existing ones. But mining firms are right that, in practice, this is still a change in the rules of the game. Nicolás Eyzaguirre, the finance minister, counters that the firms blocked efforts at a voluntary agreement to pay more taxes.

In Chile, the government expects to raise at least $100m a year; this will go into a special fund to promote innovation. In Peru, royalties should raise some $75m; less sensibly, this will be shared out among local governments in mining areas.

Mining firms claim that the royalties will deter investment. Probably not in Chile: it ranked as the world's most attractive destination for mining investment in a survey in January by the Fraser Institute, a Canadian think-tank. Mr Eyzaguirre points out that, at a copper price of 90 cents per lb (it is now $1.19), the royalties would reduce the industry's average return on assets only from 20% to 19.2%. This would have “no impact” on investment.

Peru risks a bigger impact: although it ranked fifth (out of 53) in the Fraser Institute index, its politics are more unstable than Chile's. And both governments will have to work hard to distinguish these economically justified measures from a crude nationalist backlash against foreign investment in the neighbourhood that this year has seen attempts to revive state oil and gas firms in Argentina and Bolivia.