Gene flow shapes spatial genetic structure as well as the potential for local adaptation of populations. Among marine animals with non-migratory adults, the presence or absence of a pelagic larval stage is thought to be a key determinant in shaping gene flow and the genetic structure of populations. In addition, the spatial distribution of suitable habitats will influence the distribution of biological populations and their pattern of gene flow. We used whole genome sequencing to study demographic history and reduced representation (ddRAD) sequencing data to analyze spatial genetic structure in the broadnosed pipefish (Syngnathus typhle). Its main habitat are seagrass meadows, which along the study coast (SW Norway) have a patchy distribution. Combining the results from several analyseis including scans for selection, suggests that stochastic genetic drift has shaped the observed population structure largely due to its patchy distribution. The. The restricted gene flow is further driven by life history traits such as the presence of parental care combined with no pelagic life stages, resulting in a clear isolation-by-distance pattern spanning 100s of kilometers.