The intraepithelial lymphocytes (IELs) that reside within the epithelium of the intestine form one of the main branches of the immune system. As IELs are located at this critical interface between the core of the body and the outside environment, they must balance protective immunity with an ability to safeguard the integrity of the epithelial barrier: failure to do so would compromise homeostasis of the organism. In this Review, we address how the unique development and functions of intestinal IELs allow them to achieve this balance.