Clean water provision is considered crucial for eradicating waterborne diseases. However, the benefits of piped water can be limited in environments characterized by the inadequate storage and disposal of waste. This article studies the impact of waterworks and sewerage on mortality in German cities during the period 1877–1913. The results show that the supply of safe drinking water reduced the number of deaths, although to a lower extent than suggested previously. In the absence of efficient systems of sewage removal, contact with faeces and water contamination created a favourable environment for the spread of enteric ailments, offsetting some of the positive effects of waterworks. Moreover, the study shows that sanitary investments had important heterogeneous effects. First, their impact was markedly lower in municipalities with high levels of economic inequality and employment in the textile sector. Second, cities located in non-Prussian territories experienced lower declines in mortality following the construction of sanitary infrastructures. The results in this article highlight the importance of analysing public health measures jointly as well as their interaction with local socioeconomic and institutional factors to understand historical progress against ill health and premature death.