Diarrheal disease remains a leading cause of morbidity in areas with limited access to safe water and sanitation. As water and sanitation interventions continue to be implemented, it will be important to understand the ecological context in which they can prevent diarrhea. We conducted six serial case control studies in Ecuador to estimate the risk of diarrhea from unimproved water and sanitation and the potential for effect modification by rainfall. Unimproved water source and unimproved sanitation increased the adjusted odds of diarrhea (odds ratio [OR] = 3.6, 95% confidence interval [95% CI] = 1.7-7.8 and OR = 1.7, 95% CI = 1.2-2.5, respectively). The OR associated with an unimproved water source was highest after maximum rainfall (OR = 6.8, 95% CI = 1.9-24.5), whereas the OR associated with unimproved sanitation was highest after minimal rainfall (OR = 2.9, 95% CI = 1.3-6.6). Our finding that use of safe water sources and improved sanitation facilities are most protective under opposing rainfall conditions highlights the need for integrated interventions to reduce the burden of diarrheal disease.