As major consumers of cellular metabolites, mitochondria are poised to compete with invading microbes for the nutrients that they need to grow. Whether cells exploit mitochondrial metabolism to protect from infection is unclear. In this work, we found that the activating transcription factor 4 (ATF4) activates a mitochondrial defense based on the essential B vitamin folate. During infection of cultured mammalian cells with the intracellular pathogen Toxoplasma gondii, ATF4 increased mitochondrial DNA levels by driving the one-carbon metabolism processes that use folate in mitochondria. Triggered by host detection of mitochondrial stress induced by parasite effectors, ATF4 limited Toxoplasma access to folates required for deoxythymidine monophosphate synthesis, thereby restricting parasite growth. Thus, ATF4 rewires mitochondrial metabolism to mount a folate-based metabolic defense against Toxoplasma.