The Tagus river, the longest in the Iberian peninsula, is in danger of drying up completely as Spain once again finds itself in the grip of drought.

Miguel Ángel Sánchez, spokesman of the Platform in Defence of the Tagus, says “the river has collapsed through a combination of climate change, water transfer and the waste Madrid produces.”

The Tagus, known in Spanish as the Tajo and Portuguese as the Tejo, rises in Aragón in northern Spain, passes close to Madrid and forms part of the border with Portugal before flowing into the sea at Lisbon. En route, it is dammed no fewer than 51 times in Spain alone.

But its troubles begin at the headwaters in Aragón. In 1902 a plan was conceived to siphon off water from here and divert it to the Segura river to irrigate farms in the arid southeast in what is known as the Tajo-Segura transfer. Construction began in 1966 and water started flowing out of the dammed Tagus headwaters to the Segura in 1979.

However, the amount of available water was miscalculated and Spain’s cyclical droughts were not factored in. Today only 47% of the predicted water resources exist and levels in the two headwater dams are down to 11% capacity, too low to allow any transfers.

“All of these problems derive from designing a water transfer from the headwaters of a river, overestimating the available resources and joining two areas with similar climate cycles,” says Nuria Hernández-Mora, a founding member of the Foundation for a New Water Culture. “The transfer has served to create social and political conflict and turn the Tagus into one of the rivers in the worst ecological state in the peninsula.”

Siphoning off the headwaters is only permitted when the dams have sufficient water – previously this was just an option, not a guarantee of supply. However, the government recently passed a law that says that as soon as there is a surplus there is an obligation to transfer it, making it impossible to store water to cope with droughts.

The law flies in the face of the European water directive and when an EU delegation visited the Tagus and Ebro rivers last year it issued a highly critical report of Spain’s failure to conform with the directive.

The Tagus’s troubles don’t end with the transfer. Even after about 65% is siphoned to the Segura, it still has to supply Madrid’s 6 million inhabitants, whose inadequately treated waste water is dumped back into the river further downstream. The water from the Tagus is also used to cool nuclear reactors.

The Portuguese complain that Spain is siphoning off water and polluting the river, arguments Spain rejects. In January Lisbon filed a formal complaint with Brussels over Spain’s plans to build a nuclear waste treatment plant close to the river and the Portuguese border.

A forest fire rages on hills across the Tagus river on 27 July, near Vila Velha de Rodao, central Portugal. Photograph: Armando Franca/AP

Spain’s water management has been driven by economics, not environmental considerations, says environmental lawyer María Soledad Gallego. “A river isn’t just a water resource, it has a cultural, social, historic and aesthetic value.”

In terms of water, Spain is living beyond its means. Agricultural demand in the Segura basin has been rising for decades, says Hernández-Mora, resulting in the over-exploitation of both ground and surface water. Water will always be a scarce resource in Spain, she says, and what needs to be controlled is demand.

While much is made of the transferred water being used to irrigate golf courses in arid Murcia, 85% of it is used to grow fruit and vegetables under plastic in that province and neighbouring Almería.

“We need to face reality and deal with the environmental implications,” says Gallego. “In the south-east agriculture is subsidised in the form of water transfers. They depend on there being a water surplus in other parts of the country and so they are always going to have problems. They need to live with the reality of what the Segura and Tajo basins can provide.”