Stable core microbial communities have been described in numerous animal species and are commonly associated with fitness benefits for their hosts. Recent research, however, highlights examples of species whose microbiota are transient and environmentally derived. Here, we test the effect of diet on gut microbial community assembly in the spider Badumna longinqua. Using 16S rRNA gene amplicon sequencing combined with quantitative PCR, we analyzed diversity and abundance of the spider's gut microbes, and simultaneously characterized its prey communities using nuclear rRNA markers. We found a clear correlation between community similarity of the spider's insect prey and gut microbial DNA, suggesting that microbiome assembly is primarily diet‐driven. This assumption is supported by a feeding experiment, in which two types of prey—crickets and fruit flies—both substantially altered microbial diversity and community similarity between spiders, but did so in different ways. After cricket consumption, numerous cricket‐derived microbes appeared in the spider's gut, resulting in a rapid homogenization of microbial communities among spiders. In contrast, few prey‐associated bacteria were detected after consumption of fruit flies; instead, the microbial community was remodelled by environmentally sourced microbes, or abundance shifts of rare taxa in the spider's gut. The reshaping of the microbiota by both prey taxa mimicked a stable core microbiome in the spiders for several weeks post feeding. Our results suggest that the spider's gut microbiome undergoes pronounced temporal fluctuations, that its assembly is dictated by the consumed prey, and that different prey taxa may remodel the microbiota in drastically different ways.