Fungal endophytes are symbionts that inhabit aboveground tissues of most terrestrial plants and can affect plant physiology and growth under stressed conditions. In a future faced with substantial climate change, endophytes have the potential to play an important role in plant stress resistance. Understanding both the distributions of endophytes and their functioning in symbiosis with plants are key aspects of predicting their role in an altered climate. Here we characterized endophytes in grasses across a steep precipitation gradient to examine the relative importance of environmental and spatial factors in structuring endophyte communities. We also tested how 20 endophytes isolated from drier and wetter regions performed in symbiosis with grass seedlings under high and low soil moisture in the greenhouse. Environmental factors related to historical and current precipitation were the most important predictors of endophyte communities in the field. On average, endophytic fungi from western sites also reduced plant water loss in the greenhouse compared to fungi from eastern sites. However, there was substantial variability in how individual endophytic taxa affected plant traits under high and low water availability, with up to two orders of magnitude difference in the plasticity of plant traits conferred by the different fungal taxa. While species sorting appears to largely explain local endophyte community composition, their function in symbiosis is not predictable from local environmental conditions. The development of a predictive framework for endophyte function will require further study of individual fungal taxa and genotypes across environmental gradients.