Investments for upgrading wastewater treatment plants (WWTPs) with tertiary treatment to reduce microcontaminant loads in surface waters at a catchment scale can be daunting. These investments are highly sensitive to the selection of environmental quality standards (EQSs) for the target microcontaminants. Our hypothesis is that there is a balance between EQS selection and investment that needs to be considered in decision-making. We used a customized microcontaminant fate and transport model coupled to an optimization algorithm to validate this hypothesis in the Llobregat river basin and for the pharmaceutical compound diclofenac. The algorithm optimizes the number of WWTPs in this catchment requiring an upgrade to minimize the total amount of diclofenac that exceeds the EQS in every river section and the total cost. We simulated and optimized 40 scenarios representing a combination of 4 potential EQSs (10, 30, 50 and 100 ng L−1), 5 levels of uncertainty bounds in the predictions of river concentrations and 2 hydrological scenarios (average flows, flows annually exceeding 30% of the days; and environmental flows, flows annually exceeding 99% of the days). The results showthat there is a nonlinear relationship between the EQS and the required investment. The investment increases by 100% from an EQS of 100 ng L−1 to 10 ng L−1, significantly increasing (by 60%) from 30 to 10 ng L−1. Thus, establishing an EQS of 30 ng L−1 would balance environmental protection and costs. The selection of the hydrological conditions also plays a key role in the upgrade analysis because the costs for environmental flows are 50% higher than for average flows. Finally, we highlight that the investment in research would allow the reduction of uncertainties, hence allowing more qualified decisions to be made and a reduction in the WWTP upgrade costs (up to 4 €·household−1·year−1).