Recent agroeconomic studies in water-scarce countries such as Spain, Australia, Saudi Arabia, and Israel have revealed the economic viability of irrigating high-value crops with desalinated water. However, the worldwide growth of large-scale desalination capacities is primarily designed to resolve urban-water scarcity, disregarding the impact of desalination on irrigation-water salinity. We develop a dynamic hydroeconomic programming model where infrastructure capacities and allocations of water quantities and salinities in a regional water distribution network are endogenous. We show that subsidizing desalination is socially warranted because the associated reduction in irrigation-water salinity is an external effect of water consumption by all water users. Empirical application to the entire state of Israel indicates that large-scale desalination of seawater and treated wastewater for irrigation is optimal. This result stems from the large share of irrigation-intensive salinity-sensitive high-value crops, motivated by Israel's policies to support local agriculture. Ignoring salinity results in a 45% reduction in desalinated irrigation water, a 29% reduction in farming profits, a 250% increase in water suppliers' profits, and an average deadweight loss of $1,200 a year per hectare of arable land.