Over the past 1000 years, rats (Rattus spp.) have become one of the most successful and prolific pests in human society. Despite their cosmopolitan distribution across six continents and ubiquity throughout the world’s cities, rat urban ecology remains poorly understood. We investigate the role of human foods in brown rat (Rattus norvegicus) diets in urban and rural areas over a 100 year period (ca AD 1790–1890) in Toronto, Canada using stable carbon (d13C) and nitrogen (d15N) isotope analyses of archaeological remains. We found that rat diets from urban sites were of higher quality and were more homogeneous and stable over time. By contrast, in rural areas, they show a wide range of dietary niche specializations that directly overlap, and probably competed, with native omnivorous and herbivorous species. These results demonstrate a link between rodent diets and human population density, providing, to our knowledge, the first long-term dietary perspective on the relative value of different types of human settlements as rodent habitat. This study highlights the potential of using the historical and archaeological record to provide a retrospective on the urban ecology of commensal and synanthropic animals that could be useful for improving animal management and conservation strategies in urban areas.