Climate change has a strong impact on species ranges and the genetic structure of populations, yet conclusions are often subject to large uncertainties when both are analysed independently. Here, we develop a novel framework to directly integrate population genetics and dynamic species distribution modelling to reduce such uncertainties when reconstructing the post-glacial history of black pepper.