Fungi associated with photosynthetic organisms are major determinants of terrestrial biomass, nutrient cycling, and ecosystem productivity from the poles to the equator. Whereas most fungi are known because of their fruit bodies (e.g., saprotrophs), symptoms (e.g., pathogens), or emergent properties as symbionts (e.g., lichens), the majority of fungal diversity is thought to occur among species that rarely manifest their presence with visual cues on their substrate (e.g., the apparently hyperdiverse fungal endophytes associated with foliage of plants). Fungal endophytes are ubiquitous among all lineages of land plants and live within overtly healthy tissues without causing disease, but the evolutionary origins of these highly diverse symbionts have not been explored. Here, we show that a key to understanding both the evolution of endophytism and the diversification of the most species-rich phylum of Fungi (Ascomycota) lies in endophyte-like fungi that can be isolated from the interior of apparently healthy lichens. These “endolichenic” fungi are distinct from lichen mycobionts or any other previously recognized fungal associates of lichens, represent the same major lineages of Ascomycota as do endophytes, largely parallel the high diversity of endophytes from the arctic to the tropics, and preferentially associate with green algal photobionts in lichen thalli. Using phylogenetic analyses that incorporate these newly recovered fungi and ancestral state reconstructions that take into account phylogenetic uncertainty, we show that endolichenism is an incubator for the evolution of endophytism. In turn, endophytism is evolutionarily transient, with endophytic lineages frequently transitioning to and from pathogenicity. Although symbiotrophic lineages frequently give rise to free-living saprotrophs, reversions to symbiosis are rare. Together, these results provide the basis for estimating trophic transition networks in the Ascomycota and provide a first set of hypotheses regarding the evolution of symbiotrophy and saprotrophy in the most species-rich fungal phylum.