The response of the gut microbiota to changes in the host environment can be influenced by both the host's past and present habitats. To quantify their contributions for two different life stages, we studied the gut microbiota of wild bank voles (
Clethrionomys glareolus
) by performing a reciprocal transfer experiment with adults and their newborn offspring between urban and rural forests in a boreal ecosystem. Here, we show that the post-transfer gut microbiota in adults did not shift to resemble the post-transfer gut microbiota of animals ‘native’ to the present habitat. Instead, their gut microbiota appear to be structured by both their past and present habitat, with some features of the adult gut microbiota still determined by the past living environment (e.g. alpha diversity, compositional turnover). By contrast, we did not find evidence of the maternal past habitat (maternal effects) affecting the post-transfer gut microbiota of the juvenile offspring, and only a weak effect of the present habitat. Our results show that both the contemporary living environment and the past environment of the host organism can structure the gut microbiota communities, especially in adult individuals. These data are relevant for decision-making in the field of conservation and wildlife translocations.