An excellent model to elucidate the mechanisms and importance of evolution in the marine environment is the spectral tuning mechanism of the visual pigment in vertebrates. In the sand goby Pomatoschistus minutus (Teleostei; Gobiidae), a distribution-wide study showed that spatial variation at the rhodopsin gene (RH1) matches the characteristics of specific light environments. This match suggests that populations are locally adapted to selective light regimes targeting the RH1 gene. If so, then the direction of selection should depend on the regional spatial and temporal stability of the light conditions. We tested this prediction by comparing goby populations from two regions: the Baltic Sea, characterized by divergent, but temporally stable light conditions, and the North Sea, characterized by locally heterogeneous and temporally variable light conditions. RH1 sequences of 491 Pomatoschistus minutus individuals from 15 locations were analysed. We found that variation at the RH1 gene in the Baltic populations showed signatures of diversifying selection, whereas the RH1 gene in the North Sea showed signatures of stabilizing selection. These different modes of selection are consistent with the regional light conditions and hence support our predictions, but may also be influenced by migration between the open sea and more turbid estuarine environments. An interesting observation is that within one gene, synonymous and non-synonymous SNPs show a totally different pattern between populations. Population differentiation based on non-synonymous SNPs of the RH1 gene correlated with spectral variation of the local environment of the sand goby populations. In contrast, the differentiation based on synonymous SNPs of RH1 reflects more the neutral historical pattern of the species.