Diarrhoeal diseases are major causes of morbidity and mortality in developing countries. This longitudinal study aimed to identify controllable environmental drivers of intestinal infections amidst a highly contaminated drinking water supply in urban slums and villages of Vellore, Tamil Nadu in southern India. Three hundred households with children (<5 years) residing in two semi-urban slums and three villages were visited weekly for 12–18 months to monitor gastrointestinal morbidity. Households were surveyed at baseline to obtain information on environmental and behavioural factors relevant to diarrhoea. There were 258 diarrhoeal episodes during the follow-up period, resulting in an overall incidence rate of 0·12 episodes/person-year. Incidence and longitudinal prevalence rates of diarrhoea were twofold higher in the slums compared to rural communities (P < 0·0002). Regardless of study site, diarrhoeal incidence was highest in infants (<1 year) at 1·07 episodes/person-year, and decreased gradually with increasing age. Increasing diarrhoeal rates were associated with presence of children (<5 years), domesticated animals and low socioeconomic status. In rural communities, open-field defecation was associated with diarrhoea in young children. This study demonstrates the contribution of site-specific environmental and behavioural factors in influencing endemic rates of urban and rural diarrhoea in a region with highly contaminated drinking water.