In the tropics, smallholder farming characterizes some of the world's most biodiverse landscapes. Agroecology as a pathway to sustainable agriculture has been proposed and implemented in sub-Saharan Africa, but the effects of agricultural practices in smallholder agriculture on biodiversity and ecosystem services are understudied. Similarly, the contribution of different landscape elements, such as shrubland or grassland cover, on biodiversity and ecosystem services to fields remains unknown.We selected 24 villages situated in landscapes with varying shrubland and grassland cover in Malawi. In each village, we assessed biodiversity of eight taxa and ecosystem services in relation to crop type, shrubland and grassland cover and the number of agroecological pest and soil management practices on smallholder's fields of different crop types (bean monoculture, maize-bean intercrop and maize monoculture).Increasing shrubland cover altered carabid and soil bacteria communities. Carabid abundance increased in maize but decreased in intercrop and bean fields with increasing shrubland cover. Carabid abundance and richness and wasp abundance increased with soil management practices. Carabid, spider and parasitoid abundances were higher in bean monocultures, but this was modulated by surrounding shrubland cover. Natural enemy abundances in beans were especially high in landscapes with little shrubland, possibly leading to lower bean damage in monocultures compared to intercropped fields, whereas maize monocultures had higher damage. In maize, grassland cover and pest management practices were positively related to damage. Carabid abundance was higher fields with high bean damage, and increased carabid richness in fields with high maize damage. Parasitoid abundance was negatively associated with bean damage.Synthesis and application. Our results suggest that maintaining biodiversity and ecosystem services on smallholder farms is not achievable with a 'one size fits all' approach but should instead be adapted to the landscape context and the priorities of smallholders. Shrubland is important to maintain carabid and soil bacterial diversity, but legume cultivation beneficial to natural enemies could complement pest management in landscapes with a low shrubland cover. An increased number of agroecological soil management practices can lead to improved pest control while the effectiveness of agroecological pest management practices needs to be re-evaluated