The earthworm species Lumbricus terrestris L. feeds on plant litter mixed with surrounding soil. Here, we analyzed with a mesocosm approach and soil incubations how that activity and subsequent ageing of casts (feces) affects the abundance and diversity of the soil microbiome. Earthworms were fed either with straw of sainfoin (SA, Onobrychis viciifolia; C/N ratio 22) or winter wheat (WW, Triticum aestivum, C/N ratio 101). The gut transit increased the abundances of bacteria and fungi, but reduced archaea. As indicated at the DNA and RNA level, main beneficiaries of the facilitated access to nutrients were members of Bacteroidota, especially Flavobacteriales with an estimated generation time of only 2 h. While Alphaproteobacteria were reduced, Gammaproteobacteria also increased in abundance and activity. SA was more nutritious for L. terrestris, and supported a higher bacterial abundance, probably because more N was available for growth and denitrification. During cast ageing, prokaryotic community compositions became increasingly similar to bulk soil communities. However, they remained distinguishable even after 168 d, suggesting that effects can last beyond a vegetation period. Dry-wet conditions preserved these differences better than continuous moisture. During ageing, more complex prokaryotic networks were detected with WW and dry-wet conditions. Thus, N and water limitations appeared to enhance cooperation rather than competition between the prokaryotes. Overall, this study demonstrates that earthworm soil interactions strongly affect the diversity and temporal dynamics of the soil microbiome. Legacy effects of earthworm activities should thus be kept in mind when investigating the environmental variation of soil microbiomes.