Abstract The conversion of biodiversity‐rich woodland to farmland and subsequent management has strong, often negative, impacts on biodiversity. In tropical smallholder agricultural landscapes, the impacts of agriculture on insect communities, both through habitat change and subsequent farmland management, is understudied. The use of agroecological practices has social and agronomic benefits for smallholders. Although ecological co‐benefits of agroecological practices are assumed, systematic empirical assessments of biodiversity effects of agroecological practices are missing, particularly in Africa. In Malawi, we assessed butterfly abundance, species richness, species assemblages and community life‐history traits on 24 paired woodland and smallholder‐managed farmland sites located across a gradient of woodland cover within a 1 km radius. We tested whether habitat type (woodland vs. farmland) and woodland cover at the landscape scale interactively shaped butterfly communities. Farms varied in the implementation of agroecological pest and soil management practices and flowering plant species richness. Farmland had lower butterfly abundances and approximately half the species richness than woodland. Farmland butterfly communities had, on average, a larger wingspan than woodland site communities. Surprisingly, higher woodland cover in the landscape had no effect on butterfly abundance in both habitats. In contrast, species richness was higher with higher woodland cover. Butterfly species assemblages were distinct between wood‐ and farmland and shifted across the woodland cover gradient. Farmland butterfly abundance, but not species richness, was higher with higher flowering plant species richness on farms. Farms with a higher number of agroecological pest management practices had a lower abundance of the dominant butterfly species, but not of rarer species. However, a larger number of agroecological soil management practices was associated with a higher abundance of rarer species. Synthesis and applications: We show that diversified agroecological soil practices and flowering plant richness enhanced butterfly abundance on farms. However, our results suggest that on‐farm measures cannot compensate for the negative effects of continued woodland conversion. Therefore, we call for more active protection of remaining African woodlands in tandem with promoting agroecological soil management practices and on‐farm flowering plant richness to conserve butterflies while benefiting smallholders.