In the mountains above the Peruvian capital Lima, the world’s second largest desert city, scientists are working with farmers to restore ancient canals, believed to predate the Inca empire, in an effort to tackle the city’s increasing water shortage.

The system – known locally as mamanteo, a term derived from the Spanish word for suckling, or amunas – could help the city of nearly 10 million inhabitants to ride the seasonal extremes of floods and droughts.

It works by funnelling water from highland streams into the mountain itself, where it percolates through cracks and natural aquifers over months to emerge in springs and natural reservoirs.

“It’s all about building in delays in the hydrological runoff of these catchments because if the water continues through this stream it will reach the village downstream in a question of hours. Letting it seep through the mountain, we expect to build in delays of weeks and hopefully months,” says Bert De Bièvre, an expert on Andean water basins working with the Consortium for the Sustainable Development of the Andean Ecorregion, an NGO.

The delay means that the abundant wet-season moisture in these highlands at more than 3,500 metres above sea level can be gradually distributed during the dry season, which can last more than half the year.

Floods and landslides killed nine people, left thousands homeless and caused major infrastructure damage on the outskirts of Lima in March. Meanwhile, unusually warm autumn temperatures brought drought in other parts of the city, where at least 700,000 live without running, potable water, according to Sedapal, the city’s water board.

A third of Peruvians live in Lima and up to 150,000 migrants continue to swell its infrastructure-starved peripheries every year. Authorities are struggling to supply the growing population, dependent on three rivers that flow from the Andes: the Rímac, Chillón and Lurín.

Regrouting and maintaining the pre-Inca drainage canals provides a cheap alternative to building modern hydric infrastructure, according to De Bièvre. Experts believe they may have been built by the Wari culture as long ago as 700AD, yet De Bièvre says it is clear they were “developed over centuries by different cultures … and we are just one more of them”.

State funding for the project began in March. Peru’s national water regulatorSunass multiplied the proposed budget, diverting 1% of consumer tariffs from Sedapal over the next five years – more than 70m Peruvian soles, or about $22m (£14m) – to green infrastructure. This will include restoring amunas and recuperating highland wetlands. A further 3.8% of tariffs, approximately $89m, will be used for climate change adaptation and disaster risk mitigation.

The investment in green infrastructure would mean an increase in Lima’s water volume by at least one cubic metre a second, which makes it “very affordable” in contrast to building a canal, said Fernando Momiy, the president of Sunass.

“Lima is a desert city which keeps growing and in five years there will be another 700,000 inhabitants who will need water. That’s why we need to look at combining grey infrastructure with green infrastructure,” said Momiy.

“It’s the first time that a regulatory body has promoted this kind of infrastructure in Lima. We see that there’s a lot of focus on grey infrastructure when we should be looking at green infrastructure, so as not to have to invest so much in expensive grey infrastructure.”

Pointing to water crises in California, the UK and Sao Paulo in Brazil, Momiy said: “There’s no reason to think that couldn’t happen to us.”

With a commanding view of the distant smog above Lima, the small district of Huamantanga feels far removed from the city that houses a third of Peruvians.

“Here we count on the expertise of the local people who know all the water sources and springs,” says De Bièvre.