Fungi have crucial roles in modern ecosystems as decomposers and pathogens, and they engage in a variety of mutualistic associations with other organisms, especially plants. They have a lengthy geological history, and there is an emerging understanding of their impact on the evolution of Earth systems on a large scale. In this Review, we focus on the roles of fungi in the establishment and early evolution of land and freshwater ecosystems. Today, questions of evolution over deep time are informed by discoveries of new fossils and evolutionary analysis of new genomes. Inferences can be drawn from evolutionary analysis by comparing the genes and genomes of fungi with the biochemistry and development of their plant and algal hosts. We then contrast this emerging picture against evidence from the fossil record to develop a new, integrated perspective on the origin and early evolution of fungi.