Intestinal epithelial cells absorb nutrients, respond to microbes, function as a barrier and help to coordinate immune responses. Here we report profiling of 53,193 individual epithelial cells from the small intestine and organoids of mice, which enabled the identification and characterization of previously unknown subtypes of intestinal epithelial cell and their gene signatures. We found unexpected diversity in hormone-secreting enteroendocrine cells and constructed the taxonomy of newly identified subtypes, and distinguished between two subtypes of tuft cell, one of which expresses the epithelial cytokine Tslp and the pan-immune marker CD45, which was not previously associated with non-haematopoietic cells. We also characterized the ways in which cell-intrinsic states and the proportions of different cell types respond to bacterial and helminth infections: Salmonella infection caused an increase in the abundance of Paneth cells and enterocytes, and broad activation of an antimicrobial program; Heligmosomoides polygyrus caused an increase in the abundance of goblet and tuft cells. Our survey highlights previously unidentified markers and programs, associates sensory molecules with cell types, and uncovers principles of gut homeostasis and response to pathogens.