The rapid human‐driven changes in the environment during the Anthropocene have placed extreme stress on many plants and animals. Beneficial interactions with microorganisms may be crucial for ameliorating these stressors and facilitating the ecosystem services host organisms provide. Foliar endophytes, microorganisms that reside within leaves, are found in essentially all plants and can provide important benefits (e.g., enhanced drought tolerance or resistance to herbivory). However, it remains unclear how important the legacy effects of the abiotic stressors that select on these microbiomes are for affecting the degree of stress amelioration provided to their hosts. To elucidate foliar endophytes' role in host‐plant salt tolerance, especially if salinity experienced in the field selects for endophytes that are better suited to improve the salt tolerance of their hosts, we combined field collections of 90 endophyte communities from 30 sites across the coastal Everglades with a manipulative growth experiment assessing endophyte inoculation effects on host‐plant performance. Specifically, we grew >350 red mangrove (Rhizophora mangle) seedlings in a factorial design that manipulated the salinity environment the seedlings experienced (freshwater vs. saltwater), the introduction of field‐collected endophytes (live vs. sterilized inoculum), and the legacy of salinity stress experienced by these introduced endophytes, ranging from no salt stress (0 parts per thousand [ppt] salinity) to high salt stress (40 ppt) environments. We found that inoculation with field‐collected endophytes significantly increased mangrove performance across almost all metrics examined (15%–20% increase on average), and these beneficial effects typically occurred when the endophytes were grown in saltwater. Importantly, our study revealed the novel result that endophyte‐conferred salinity tolerance depended on microbiome salinity legacy in a key coastal foundation species. Salt‐stressed mangroves inoculated with endophyte microbiomes from high‐salinity environments performed, on average, as well as plants grown in low‐stress freshwater, while endophytes from freshwater environments did not relieve host salinity stress. Given the increasing salinity stress imposed by sea level rise and the importance of foundation species like mangroves for ecosystem services, our results indicate that consideration of endophytic associations and their salinity legacy may be critical for the successful restoration and management of coastal habitats.