Fragmented natural habitats within human-transformed landscapes play a key role in preserving biodiversity. Ants as keystone species are essential elements of terrestrial ecosystems; thus, it is important to understand the factors influencing their presence. In a large-scale multi-site study, we surveyed ant assemblages using sweep netting and D-vac sampling on 158 ancient burial mounds preserving grassland habitats in agricultural landscapes in East-Hungary. We asked the following questions: (1) How do habitat factors and landscape composition affect species richness and functional diversity of ants? (2) Which ant traits are affected by habitat factors and landscape composition? Despite their small sizes, mounds as permanent and relatively undisturbed landscape elements could provide safe havens for diverse ant assemblages even in transformed agricultural landscapes. The complex habitat structure of wooded mounds supported high species and functional diversity of ant assemblages. Ant species on wooded mounds had small or medium-sized colonies, enabling the co-existence of more species. The effect of landscape composition on ant assemblages was mediated by habitat factors: steep slopes buffered the negative effect of the cropland matrix and enabled higher ant diversity.