Maternal stress during gestation is associated with an increased risk of neurodevelopmental disorders in offspring. The gut-brain axis is considered a potential mediating pathway. As a key component of the gut microbiome, the bacteriophages can remodel bacterial community structure and function. However, whether gut viruses contribute to prenatal stress-induced behavioral alterations in offspring remains unclear. Here, we reported that prenatal stress induces anxiety-like behaviors and alters the gut virome and bacteriome specifically in male offspring. By comparing the gut virome and bacteriome between dams and their offspring, we found that the gut microbial profile of male offspring is more similar to that of their mothers than that of female offspring. To investigate whether changes in the gut virome are causally linked to stress-related behavioral or physiological outcomes, we transplanted gut viromes from control offspring into the offspring exposed to maternal prenatal stress. The results showed that transplantation of the gut virome from control offspring alleviated anxiety-like behaviors, restored the gut microbiome, and modulated immune responses in prenatally stressed offspring. Our findings highlight the critical role of gut bacteriophages in mediating prenatal stress-induced behavioral changes and demonstrate that fecal virome transplantation (FVT) can mitigate such alterations. Thus, we establish a causal link between prenatal stress, the gut virome, immune function, and behavior, pointing to FVT as a potential therapeutic strategy for certain neurodevelopment-related behavioral abnormalities.