Metapopulation theory predicts that species richness and total population density of habitat specialists increase with increasing area and regional connectivity of the habitat. To test these predictions, we examined the relative contributions of habitat patch area, connectivity of the regional habitat network and local habitat quality to species richness and total density of butterflies and day-active moths inhabiting semi-natural grasslands. We studied butterflies and moths in 48 replicate landscapes situated in southwest Finland, including a focal patch and the surrounding network of other semi-natural grasslands within a radius of 1.5 km from the focal patch. By applying the method of hierarchical partitioning, which can distinguish between independent and joint contributions of individual explanatory variables, we observed that variables of the local habitat quality (e.g. mean vegetation height and nectar plant abundance) generally showed the highest independent effect on species richness and total density of butterflies and moths. Habitat area did not show a significant independent contribution to species richness and total density of butterflies and moths. The effect of habitat connectivity was observed only for total density of the declining butterflies and moths. These observations indicate that the local habitat quality is of foremost importance in explaining variation in species richness and total density of butterflies and moths. In addition, declining butterflies and moths have larger populations in well-connected networks of semi-natural grasslands. Our results suggest that, while it is crucial to maintain high-quality habitats by management, with limited resources it would be appropriate to concentrate grassland management and restoration to areas with well-connected grassland networks in which the declining species currently have their strongest populations.