The digestive tract of animals harbors microbiota important for the host's fitness and performance. The interaction between digestive tract bacteria and soil animal hosts is still poorly explored despite the importance of soil fauna for ecosystem processes. In this study, we investigated the interactions between the bacterial communities from the digestive tract of the litter-feeding, semi-terrestrial crustacean Orchestia gammarellus and those obtained from the environment; these organisms thrive in, i.e., soil and plant litter from salt marshes. We hypothesized that elevation is an important driver of soil and litter bacterial communities, which indirectly (via ingested soil and litter bacteria) influences the bacterial communities in the digestive tract of O. gammarellus. Indeed, our results revealed that elevation modulated soil and litter bacterial community composition along with soil organic matter content and the C:N ratio. Soil and plant litter differed in alpha diversity indexes (richness and diversity), and in the case of plant litter, both indexes increased with elevation. In contrast, elevation did not affect the composition of bacterial communities associated with O. gammarellus' digestive tract, suggesting selection by the host, despite the fact that a large component of the bacterial community was also detected in external sources. Importantly, Ca. Bacilloplasma and Vibrio were highly prevalent and abundant in the host. The taxonomic comparison of Ca. Bacilloplasma amplicon sequence variants across the host at different elevations suggested a phylogenetic divergence due to host habitat (i.e., marine or semi-terrestrial), thus supporting their potential functional role in the animal physiology. Our study sheds light on the influence of the environment on soil animal-bacteria interactions and provides insights into the resilience of the O. gammarellus-associated bacteria to increased flooding frequency.