Key message: This first pan-Mediterranean analysis of genetic diversity in wild narrow-leafed lupin revealed strong East–West genetic differentiation of populations, an historic eastward migration, and signatures of genetic adaptation to climatic variables. Abstract: Most grain crops suffer from a narrow genetic base, which limits their potential for adapting to new challenges such as increased stresses associated with climate change. Plant breeders are returning to the wild ancestors of crops and their close relatives to broaden the genetic base of their crops. Understanding the genetic adaptation of these wild relatives will help plant breeders most effectively use available wild diversity. Here, we took narrow-leafed lupin (Lupinus angustifolius L.) as a model to understand adaptation in a wild crop ancestor. A set of 142 wild accessions of narrow-leafed lupin from across the Mediterranean basin were subjected to genotyping-by-sequencing using Diversity Arrays Technology. Phylogenetic, linkage disequilibrium and demographic analyses were employed to explore the history of narrow-leafed lupin within the Mediterranean region. We found strong genetic differentiation between accessions from the western and eastern Mediterranean, evidence of an historic West to East migration, and that eastern Mediterranean narrow-leafed lupin experienced a severe and recent genetic bottleneck. We showed that these two populations differ for flowering time as a result of local adaptation, with the West flowering late while the East flowers early. A genome-wide association study identified single nucleotide polymorphism markers associated with climatic adaptation. Resolving the origin of wild narrow-leafed lupin and how its migration has induced adaptation to specific regions of the Mediterranean serves as a useful resource not only for developing narrow-leafed lupin cultivars with greater resilience to a changing climate, but also as a model which can be applied to other legumes.