Abstract Nitrogen pollution is one of the main problems affecting the environment and human activity. This is especially true in semiarid regions where the quantity-quality relationship is a key constraining factor. In this paper, we propose and apply a method to quantify the economic value of the environmental service a river provides as a nitrate purifier/diluent. The main aim is to provide water management decisions with a solid and easily replicable method. Specifically, this study proposes a method to assess two processes of the water quality regulation service, namely, nitrate removal and dilution, through avoided decontamination costs. The proposed method is applied in the Ebro river basin as a role model. This application allows us to define the concepts in an operational manner. Since water availability forecasts are a key factor, we explore and analyze our results in accordance with several climate-change scenarios. The results show that the economic value of the removal service at the watershed scale amounts to about €92.3 million per year. Estimates of the annual economic value of the dilution service in the whole basin range more largely from €21.8 to €111.7 million, depending on the climate change scenario considered. To our knowledge, this is the first time that the dilution and removal services provided by rivers are jointly assessed.