In Alicante it never rains but it pours. The city in southeast Spain goes without rain for months on end, but when it comes it’s torrential, bringing destructive and sometimes fatal flooding.

Or at least, it used to. In San Juan, a low-lying area of the city, authorities have built a new park with a twist. Called La Marjal, it serves as a typical recreation area and a nature reserve – but its primary purpose is to store, and then recycle, rainwater.

In function it resembles an aljibe, a technique developed by Arab residents of Spain many centuries ago, in which rainwater is collected and stored in a kind of cistern underneath a building. La Marjal does a similar job, but outdoors. The water is also then diverted to a nearby treatment plant, where it can subsequently be used to clean streets and water parks.

“The need for sustainable management has forced us to recover ancestral practices,” says Jorge Olcina, professor of analytical geography at the University of Alicante. “You could say that these rainwater storage facilities in Alicante and Barcelona are the new aljibes of the 21st century.”

La Marjal after heavy rain in 2017. The park has the capacity of 18 Olympic pools. Photograph: JLC Creativos Agency

Over eight centuries, the Arab rulers of Spain became masters of water management and conservation. Much of this knowledge was lost when they were expelled en masse in the early 17th century.

The park uses some of the same principles as the aljibe. “When the rainfall is too heavy for the storm drains to cope, the overflow is diverted to the park,” explains Amelia Navarro, director of sustainable development for the Alicante water authority.

“It has the capacity of 18 Olympic pools but it’s never reached more than 30%,” she says, not even after its first big in test 2017 when there was unusually heavy rain.

The park has been landscaped with native Mediterranean plants and rapidly populated by resident and migratory birds and small creatures, a fitting development given that marjal is the Spanish word for a coastal wetland. Since it opened in 2015, around 90 species of birds have been spotted in the park, an oasis among apartment blocks.

When rainfall is too heavy for the city’s storm drains to cope, the overflow is diverted to the park. Photograph: Juan Carlos Soler

“We introduced larvae-eating fish so that we don’t get mosquitoes,” said Navarro, adding that the water is oxygenated to reduce algae growth.

When storms break, rising water levels trip an acoustic alarm to warn people to leave. The park is then closed until the rain eases off.

La Marjal was built in two years for €3.7 million, a quarter of the cost of the city’s traditional concrete reservoir. It also costs only €50,000 a year to maintain.

“We’re the ones who end up running these projects so they have to be affordable,” says Miguel Rodríguez, head of operations at the public-private Aguas de Alicante. “Ultimately, the public pays so we have to keep costs down.”

Although the park is a clever and relatively inexpensive solution, Spain’s urban water authorities have been generally slow to adapt to the climate crisis, says Leandro del Moral, professor of human geography at the University of Seville. Only Madrid, Cádiz and Seville have made any significant progress, he says.

Since it opened in 2015, around 90 species of birds have been spotted in the park, while larvae-eating fish keep the mosquito population down. Photograph: Aguas de Alicante

The country’s water plans, announced every five years, now predict that 10-15% less water will be available in the near future, as higher temperatures brought on by global heating mean more water is lost through evaporation and plant respiration.

“Even if it rains as much as before there will be less water,” says Del Moral. “This is a clear message that climate change is having an impact. Cities need to anticipate, not react to, the increased risk of drought.”

“We need new infrastructures, which are very expensive,” says Francisco Bartual, managing director of Aguas de Alicante. “We have upgraded the water network to the point that it’s operating at around 90%, which means we’re letting very little water go to waste.”

But water is a scarce resource and political interests often trump environmental ones. Although agriculture accounts for only 3% of GDP, it takes up 80% of water consumption – and farmers are a major voting bloc. Water gets diverted from wet regions to dry, and Spain’s few major rivers are interrupted by hundreds of dams, all of which impacts the big cities.

“Agriculture has to reduce water consumption when there is danger of drought, not when it has already arrived, when it is too late,” says Del Moral. “But this is a political hot potato.” Storing and recycling water, as La Marjal was designed to do, are rising up the list of alternatives. Luckily, old habits die hard.

Follow Guardian Cities on Twitter, Facebook and Instagram to join the discussion, catch up on our best stories or sign up for our weekly newsletter