Yet climate change now threatens some of these ambitious undertakings, reducing lakes, diminishing aquifers and shrinking glaciers that feed crops. Here in Peru, the government irrigated the desert and turned it into farmland through an $825 million project that, in a few decades, could be under serious threat.

“We’re talking about the disappearance of frozen water towers that have supported vast populations,” said Jeffrey Bury, a professor at the University of California at Santa Cruz who has spent years studying the effects of glacier melt on Peruvian agriculture. “That is the big picture question related to climate change right now.”

A changing climate has long haunted Peru. One past civilization, the Moche people, built cities in the same deserts, only to collapse more than a millennium ago after the Pacific Ocean warmed, killing fish and causing flash floods, many archaeologists contend.

Now dwindling water is the threat. While more than half of Peru sits in the wet Amazon basin, few of its people ever settled there. Most inhabit the dry northern coast, cut off from most rain by the Andes range. While the region includes the capital, Lima, and 60 percent of Peruvians, it holds only 2 percent of the country’s water supply.

The glaciers are the source of water for much of the coast during Peru’s dry season, which extends from May to September. But the icecap of the Cordillera Blanca, long a supply of water for the Chavimochic irrigation project, has shrunk by 40 percent since 1970 and is retreating at an ever-faster rate. It is currently receding by about 30 feet a year, scientists say.

Farmers along the 100-mile watershed that winds its way from the snowcapped peaks to the desert dunes say they are already feeling the effects of the change.