Livestock depredation by wild carnivores threatens carnivore populations and livestock-dependent human communities globally. Understanding local attitudes towards carnivores can inform strategies to improve coexistence. In Sri Lanka, the dairy industry is expanding, creating a need for proactive conflict mitigation. Livestock depredation by the Endangered Sri Lankan leopard Panthera pardus kotiya occurs, but little is known about these incidents or the attitudes of those whose livelihoods may be threatened by this. We surveyed people in two rural communities, Palatupana and Maskeliya, that differed in the scale of livestock ownership, livestock management practices and socio-ecological factors, to characterize attitudes towards leopards and understand their determinants. In Palatupana, an area with extensive cattle rearing, depredation incidents were frequent, and attitudes towards leopards were positively related to respondents' age, number of dependants, years spent rearing livestock and a greater overall support for wildlife conservation. Attitudes were negatively related to respondents' knowledge of leopard ecology and awareness of leopard-related tourism, from which cattle owners do not benefit. In Maskeliya, where cattle rearing is secondary to other agricultural work, depredation did not occur. Here, attitudes were positively related to a desire for increased government assistance with cattle rearing. The inability to develop land for cattle husbandry was a common barrier experienced in both communities. Considering local attitudes can inform strategies to improve human–carnivore coexistence. Approaches that could improve attitudes towards leopards include involvement of cattle owners in tourism programmes, exploring potential alternative land ownership schemes, and improving infrastructure and access to veterinary care.