Adaptive immunity provides life-long protection by generating central and effector memory T cells and the most recently described tissue resident memory T (TRM) cells. However, the cellular origin of CD4 TRM cells and their contribution to host defense remain elusive. Using IL-17A tracking-fate mouse models, we found that a significant fraction of lung CD4 TRM cells derive from IL-17A-producing effector (TH17) cells following immunization with heat-killed Klebsiella pneumonia (Kp). These exTH17 TRM cells are maintained in the lung by IL-7, produced by lymphatic endothelial cells. During a memory response, neither antibodies, γδ T cells, nor circulatory T cells are sufficient for the rapid host defense required to eliminate Kp. Conversely, using parabiosis and depletion studies, we demonstrated that exTH17 TRM cells play an important role in bacterial clearance. Thus, we delineate the origin and function of airway CD4 TRM cells during bacterial infection, offering novel strategies for targeted vaccine design. Fate-mapping studies reveal that CD4+ tissue resident-memory cells are derived from effector TH17 cells and play essential roles in response to bacterial infections.