The opening of habitats associated with the emergence of C4 grasslands during the Neogene had a massive influence on the evolution of plant and animal communities. Strikingly, the impacts of grassland expansion on species diversification in Africa, where the largest surface of grasslands and savannas in the world is located, are not well understood. To explore the impact of habitat opening, we investigate the evolution of noctuid stemborers, a group of moths mostly associated with open habitats, and whose diversity is centered in the Afrotropics. We generate a dated molecular phylogeny for ca 80% of the known stemborer species, and assess the role of habitat opening on the evolutionary trajectory of the group through a combination of parametric historical biogeography, ancestral character state estimation, life history traits and habitat‐dependent diversification analyses. Our results support an origin of stemborers in Southern and East Africa ca 20 million years ago (Ma), with range expansions linked to the increased availability of open habitats to act as dispersal corridors, and closed habitats acting as potent barriers to dispersal. Early specialization on open habitats was maintained over time, with shifts towards closed habitats being rare and invariably unidirectional. Analyses of life history traits showed that habitat changes involved specific features likely associated with grassland adaptations, such as variations in larval behavior and color. We compare these findings to those previously inferred for an Afrotropical butterfly group that diversified roughly in parallel with the stemborers but distributed predominantly in closed habitats. Remarkably, these two groups show nearly opposite responses in relation to habitat specialization, whether in terms of biogeographical patterns, or in terms of rates of transition between open and closed habitats. We conclude that habitat opening played a major role in the evolutionary history of Afrotropical lineages through dispersal and adaptation linked to habitat shifts.