Fungus-farming ants cultivate multiple lineages of fungi for food, but, because fungal cultivar relationships are largely unresolved, the history of fungus-ant coevolution remains poorly known. We designed probes targeting >2000 gene regions to generate a dated evolutionary tree for 475 fungi and combined it with a similarly generated tree for 276 ants. We found that fungus-ant agriculture originated ~66 million years ago when the end-of-Cretaceous asteroid impact temporarily interrupted photosynthesis, causing global mass extinctions but favoring the proliferation of fungi. Subsequently, ~27 million years ago, one ancestral fungal cultivar population became domesticated, i.e., obligately mutualistic, when seasonally dry habitats expanded in South America, likely isolating the cultivar population from its free-living, wet forest-dwelling conspecifics. By revealing these and other major transitions in fungus-ant coevolution, our results clarify the historical processes that shaped a model system for nonhuman agriculture.