Many granivorous birds have shown severe population declines in Europe during recent decades. The aim of the present study was to analyse habitat preferences and reproductive success of one such species, the Ortolan Bunting Emberiza hortulana, in different farmland habitats in south-central Sweden. Four seemingly different land-use types were preferred: permanent set-asides, short rotation coppice, and grazed and unmanaged semi-natural pastures. Territories and random sites differed considerably in the proportion of these preferred land-use types; 39% of territories had > 70% preferred habitat (at the 100-m scale) compared to 5% of random sites. In contrast, 22% of territories and 65% of random sites had no preferred habitats. All the preferred habitats had heterogeneous ground vegetation characterized by patches with bare ground, or at least sparse ground vegetation, intermixed with patches with taller vegetation. Ortolan Buntings also preferred a heterogeneous habitat structure with occurrence of field islets, shrubby edges, barns and electric wires, which could act as song posts or suitable nest-sites, in 88% of territories. At a larger (1-km square) scale, territories occupied by pairs aggregated strongly in areas with high proportions of preferred habitats. The number of territories with single males correlated positively with the number of pairs, which suggests that conspecific attraction may influence territory distribution. No measured habitat factors were related to reproductive success. However, due to habitat preferences and the higher proportion of paired males in one habitat type (set-aside), the production of young (fledglings/ha) is expected to be higher in set-asides, as well as in short-rotation coppices and semi-natural pastures. Thus, these habitats are important for the conservation of the Ortolan Bunting. Large areas with habitat structures such as field islets are especially important because the Ortolan Bunting breeds in aggregations in these areas.