Understanding how environmental gradients shape the spatial patterns of intraspecific genetic diversity is a central issue in ecological and evolutionary sciences. In riverine ecosystems, there is generally an increase in neutral genetic diversity downstream, as well as an increase in genetic differentiation among upstream populations. However, selective pressures may vary markedly along the upstream–downstream gradient, which could modify these patterns, but this has rarely been tested empirically. Here, we investigated how environmental gradients in a river network could shape the spatial patterns of intraspecific genetic diversity and differentiation in both neutral SNP markers and functional genetic markers putatively under natural selection (candidate SNPs associated with physiological functions and immune Major Histocompatibility Complex (MHC) loci) in wild brown trout populations. First, we showed that both the distance from the confluence and the centrality on the river network could explain the variation in genetic diversity and differentiation. Second, we found that both neutral and functional markers followed a similar pattern, with a higher genetic diversity and a lower genetic differentiation among populations that were more central and/or near to the confluence. This study highlights the importance of considering both the spatial and hydrological factors of a river network to understand and predict the role of dendritic connectivity in the spatial patterns of genetic diversity and differentiation in wild fish populations.