Nutrient stoichiometry of phytoplankton frequently changes with aquatic ambient nutrient concentrations, which is mainly influenced by anthropogenic water treatment and the ecosystem dynamics. Consequently, the stoichiometry of phytoplankton can markedly alter the metabolism and growth of zooplankton. However, the effects of nutrient-imbalanced prey on the interplay between zooplankton and their gut microbiota remain unknown. Using metatranscriptome, a 16s rRNA amplicon-based neutral community model (NCM) and experimental validation, we investigated the interactions between Daphnia magna and its gut microbiota in a nutrient-imbalanced algal diet. Our results showed that in nutrient-depleted water, the nutrient-enriched zooplankton gut stimulated the accumulation of microbial polyphosphate in fecal pellets under phosphorus limitation and the microbial assimilation of ammonia under nitrogen limitation. Compared with the nutrient replete group, both N and P limitation markedly promoted the gene expression of the gut microbiome for organic matter degradation but repressed that for anaerobic metabolisms. In an N- and P-limited diet, the gut microbial community exhibited a higher fitting to NCM with promoted R-square value when compared with the Control group (0.624, 0.781, and 0.542 for N-limited, P-limited, and Control diet, respectively), suggesting increased ambient-gut exchange process favored by compensatory feeding. Further, an additional axenic grazing experiment revealed that bacteria can still benefit D. magna to achieve better growth under a nutrient-imbalanced diet. Together, these results demonstrated that under a nutrient-imbalanced diet, the microbes not only benefit themselves by absorbing excess nutrients inside the zooplankton gut but also help zooplankton to survive during the tough time of nutrient limitation.