TORREVIEJA, Spain>> On a fiery hot day in late June, tourists filled the cafes and hotel rooms along Spain’s Mediterranean coast, including in Torrevieja, a small city of tightly stacked apartment blocks running along a curved beach.

The seasonal population surge in this dry, sun-baked region might strain water resources were it not for a set of buildings overlooking a pink-tinged lagoon nearby.

These low-slung structures house a vast network of pipes, pumps and tanks in a plant that performs a kind of alchemy crucial to the economy of this part of Spain: drawing huge volumes of water from the sea, removing the salt and creating more than 60 million gallons of fresh water a day.

Acciona, a Spanish company that built the plant, says the facility can supply water for 1.6 million people through the process known as desalination. For much of the year, though, the output is largely used to nurture oranges, lemons and other crops for consumers in Northern Europe.

But when the crowds of tourists arrive in the summer, more water is diverted into the city’s pipes for showering and other domestic use, said Ana Boix, deputy manager of the plant. “We have a very high-quality water from a source of supply that is endless,” she said.

The Torrevieja plant is the largest of its kind in Europe, and similar plants dot the Spanish coastline. They have helped enable rampant coastal development in parched areas and to support an agricultural industry that is considered among the world’s most proficient at managing water.

With nearly 100 big plants, Spain is the largest user of desalination in Europe and one of the world’s largest. In many other countries — including Australia, China and Israel — reliance on desalination for drinking water and other needs is increasing.

Christopher Gasson, publisher of Global Water Intelligence, which tracks the industry, said that about 500 million people rely at least partly on purified salt or brackish water and that the number could rise sixfold to 3 billion by midcentury. Around the world, there are about 1,500 large plants — those that can produce about 2.6 million gallons a day — with roughly $14 billion being spent annually to operate the existing fleet and build new ones.

Several factors may make further growth almost inevitable. Coastal cities are attracting more people, outstripping natural water supplies. And climate-related droughts are becoming more common and intense, prompting governments to opt for desalination plants as an insurance policy against not only water shortages but also potential social unrest.

“I think that water will continue to be a singular point of stress, particularly in the era of climate change,” said Peter S. Fiske, executive director of the National Alliance for Water Innovation, a research body funded by the U.S. Department of Energy.

With supply pressures increasing and regulations tightening, businesses, too, may need to invest in desalination as a way of making sure their factories can keep functioning.

In addition, the costs of operating the energy-intensive desalination technology — called reverse osmosis, which is standard at large plants including the one at Torrevieja — are being brought down by pairing water purification with cheap solar energy, encouraging the building of new plants.

The lack of water resources among the countries along the Persian Gulf, combined with their wealth of both petroleum and sunshine, makes building desalination plants an obvious choice. “Desal tends to be needed where the sunshine is,” Gasson said, using an abbreviation for desalination.

Saudi Arabia is the largest market for these installations, followed by the United Arab Emirates. Access to converted seawater has helped give rise to gleaming, futuristic metropolises in places like Dubai, United Arab Emirates, and Qatar.

“Desalination allowed this spaceshiplike settlement,” said Karim Elgendy, a climate analyst at Chatham House, a London research organization.

There are concerns that the dependence of countries like Saudi Arabia on desalination could leave their citizens scrambling for water if the coastal plants malfunctioned or were attacked. Desalination “is the only way to continue having large population centers” in the region, said Karen E. Young, a senior research scholar at the Columbia University Center on Global Energy Policy.

Some analysts say worries about water scarcity and the large sums invested in desalination plants are likely to lead to breakthroughs that are cheaper, cleaner and more flexible. Sheikh Mohammed bin Zayed Al Nahyan, ruler of Abu Dhabi, the capital of the United Arab Emirates, is offering a $119 million prize to encourage innovation in the field.

Customers do grumble that desalination remains more costly than rainwater and comes with other drawbacks. The Spanish government subsidizes the bulk of the costs, but Mariano Saez, a farmer in the region near Torrevieja, says the 45 euro cents he pays per cubic meter to produce 30,000 metric tons a year of citrus fruit is still too expensive.

Spain’s rivers should be reengineered to deliver more water from other regions that would be “cheaper and healthier than the water from the desalination plants,” he said. But some analysts say that approach would be impractical and divisive.

“Economic development will continue and needs a water supply,” said Jorge Olcina, a professor of geography at the nearby Alicante University.

The Spanish government recently announced a 90 million euro (about $98 million) expansion of the Torrevieja plant, which cost around 200 million euros.

Santiago Martín Barajas, a representative of Ecologistas en Acción, an environmental group, said the concentrated salt water that flows into the sea from the plants could harm marine life, including damaging the sea vegetation where fish breed. Barajas said desalination should be limited to supplying drinking water, mainly during times of drought, and should not be used to water crops.

Acciona, the company that built the plant in Torrevieja, employed environmental consultants who regularly tested the sea and sediment around the pipes outside the city’s sea wall, where the plant’s waste flows, to check that increased salinity was within prescribed limits.

Environmental concerns have limited plant construction in some places including California, where desalination might otherwise be a logical option for dealing with severe droughts. In 2022, a state panel turned down a $1.4 billion proposal to build a plant at Huntington Beach, near Los Angeles, that could have supplied 50 million gallons of drinking water a day.

Acciona, which was set to build the California plant, sees plenty of other opportunities. It says it has the inside track to design, build and operate a smaller plant at Dana Point in Southern California. The company has also agreed to build Africa’s largest desalination plant near Casablanca in Morocco at a cost of nearly $1 billion, with a power supply that will come entirely from wind.