The vagina, which is lined with numerous commensal bacteria, is the first line of defense for the female reproductive organs. Although Firmicutes is the predominant member of the vaginal microbiota, physiological conditions, such as obesity, can alter its composition. The important role of the vaginal microbiota in protecting against sexually transmitted infection has been studied using germ-free mice or antibiotic treatment. However, the impact of natural dysbiosis, such as that induced by obesity or disease, and the effect that this has on susceptibility to infection remains unclear. Here, we found that diet-induced obesity alters the vaginal microbiome leading to arginine production. This microbiota-produced arginine enhances cytotoxicity and NKG2D expression of γδ T cells through the cyclic GMP second messenger signaling pathway, thereby protecting mice from lethal genital herpes. Thus, our work illuminates one mechanism by which compositional changes in the vaginal microbiota can affect mucosal immune responses against viral infection.