The North Sea's historical migrations have impacted the genetic structure of its neighbouring populations. We analysed haplotype sharing among 858,635 modern individuals from Denmark and Britain to infer migration history from the Middle Ages to the modern day. We estimated the genetic relationship among 370,259 Danes using Danish healthcare registries and validated those with retrievable pedigree relationships from a national family registry. We also compared their haplotype sharing with 488,376 British individuals from the UK Biobank. Our analysis revealed the fine-grained population genetic history of Denmark and identified distinct coastal and island communities with a history of genetic isolation and bottlenecks. We observed a significant population decline in Jutland compared to Zealand from the late medieval period to the start of early modern period, accompanied by migration from Jutland to Zealand, corresponding to historical evidence. We identified two major haplotype sharing patterns between Denmark and Great Britain: (1) early coast-to-coast connections between South Jutland and eastern England, likely driven by migration, settlement, continuous trade and the movement of people across the North Sea from the Middle Ages through early modern times, and (2) later city-to-city connections such as those between London and Kobenhavn, likely shaped by the reorientation of economic and trading centres in Britain and Denmark, and the increased shipping from early modern times towards the Industrial Revolution. Further comparisons using other North Sea countries showed both shared and unique histories of genetic exchange with Denmark and Britain. Our study provides novel genetic evidence of migration across the North Sea from the Middle Ages to the Industrial Revolution. It highlights the power of nationwide biobanks in reconstructing fine-scale historical population movements among closely related populations.