Structure of fungal communities is known to be influenced by host plants and environmental conditions. However, in most cases, the dynamics of these variation patterns are poorly understood. In this work, we compared richness, diversity, and composition between assemblages of endophytic and rhizospheric fungi associated to roots of two plants with different lifestyles: the halophyte Inula crithmoides and the non-halophyte I. viscosa (syn. Dittrichia viscosa L.), along a spatially short salinity gradient. Roots and rhizospheric soil from these plants were collected at three points between a salt marsh and a sand dune, and fungi were isolated and characterized by ITS rDNA sequencing. Isolates were classified in a total of 90 operational taxonomic units (OTUs), belonging to 17 fungal orders within Ascomycota and Basidiomycota. Species composition of endophytic and soil communities significantly differed across samples. Endophyte communities of I. crithmoides and I. viscosa were only similar in the intermediate zone between the salt marsh and the dune, and while the latter displayed a single, generalist association of endophytes, I. crithmoides harbored different assemblages along the gradient, adapted to the specific soil conditions. In the lower salt marsh, root assemblages were strongly dominated by a single dark septate sterile fungus, also prevalent in other neighboring salt marshes. Interestingly, although its occurrence was positively correlated to soil salinity, in vitro assays revealed a strong inhibition of its growth by salts. Our results suggest that host lifestyle and soil characteristics have a strong effect on endophytic fungi and that environmental stress may entail tight plant-fungus relationships for adaptation to unfavorable conditions.