The unparalleled diversity of tropical ecosystems like the Amazon Basin has been traditionally explained using spatial models within the context of climatic and geological history. Yet, it is adaptive genetic diversity that defines how species evolve and interact within an ecosystem. Here, we combine genome scans, population genetics and sequence-based phylogeographic analyses to examine spatial and ecological arrangements of selected and neutrally evolving regions of the genome of an Amazonian fish, Triportheus albus. Using a sampling design encompassing five major Amazonian rivers, three hydrochemical settings, 352 nuclear markers and two mitochondrial DNA genes, we assess the influence of environmental gradients as biodiversity drivers in Amazonia. We identify strong divergent natural selection with gene flow and isolation by environment across craton (black and clear colour)- and Andean (white colour)-derived water types. Furthermore, we find that heightened selection and population genetic structure present at the interface of these water types appears more powerful in generating diversity than the spatial arrangement of river systems and vicariant biogeographic history. The results from our study challenge assumptions about the origin and distribution of adaptive and neutral genetic diversity in tropical ecosystems. In addition, they have important implications for measures of biodiversity and evolutionary potential in one of the world's most diverse and iconic ecosystems.