Resource nationalism is only one of the worries that keeps mining company executives awake at night. Almost every day a new technological barrier needs be pierced to extract new resources. And even if governments welcome economic development, many new projects are taking place in ever more distant and environmentally fragile locations.

Companies and governments in countries as far-flung as India, Indonesia and Bolivia have had to confront this problem. But the country in which it is currently most keenly felt is Peru. After 11 days of protests against a gold mining project in Cajamarca, Ollanta Humala, the newly elected president, on Sunday declared a state of emergency and sent in the army to restore order.

How the standoff is settled will have far-reaching implications. As well as being the world’s sixth largest gold producer, Peru is also the second-largest producer of silver, copper and zinc. About $42bn of investment could be jeopardised if things go awry. With Peru expected to be a mainstay of growth in the global supply of metals over the next five years, that loss would be hard to offset.

The stakes are also high for Mr Humala. The leftist colonel’s election in June sparked a record sell-off on the Lima stock exchange on fears that he would take a Chávez-like stance towards business. Since then, however, he has sought to balance economic development with social inclusion, watering down a tax on miners, yet also promising to consult communities about projects that affect them.

This is the right stance to adopt. But in reality, Mr Humala had little choice: Peruvian economic output is dominated by mining; Mr Humala needs the resulting revenues to fund his ambitious social programme.

Implementation, however, will be difficult. Peru’s institutions are weak. The environment ministry lacks the teeth to call miners to account. In the remote regions where many projects are located, the state may be entirely absent. Moreover, property rights are often vague, which makes it hard to consult with owners.

Calming local fears about exploitation and damage will require the government and mining companies to work together. Some of the practical concerns can surely be met: mining companies no longer routinely wreck the environment in which they work. But they also need to find a way to engage with local communities and persuade them that the intrusion will be temporary and of overall benefit.