Understanding the factors that modulate prokaryotic assemblages and their niche partitioning in marine environments is a longstanding challenge in marine microbial ecology. This study analyzes amplicon sequence variant (ASV) diversity and co-occurrence of prokaryotic (Archaea and Bacteria) communities through coastal-oceanic gradients in the NW Iberian upwelling system and adjacent open-ocean (Atlantic Ocean). Biogeographic patterns were investigated in relation with environmental conditions, mainly focusing on the optical signature of the dissolved organic matter (DOM). Alpha- and beta-diversity were horizontally homogeneous [with the only exception of Archaea (∼1700 m depth), attributed to the influence of Mediterranean water, MW], while beta-diversity was significantly vertically stratified. Prokaryotic communities were structured in four clusters (upper subsurface, lower subsurface, intermediate, and deep clusters). Deep (>2000 m) archaeal and bacterial assemblages, and intermediate (500-2000 m) Bacteria (mainly SAR202 and SAR406), were significantly related to humic-like DOM (FDOM-M), while intermediate Archaea were additionally related to biogeochemical attributes of the high-salinity signature of MW. Lower subsurface (100-500 m) Archaea (particularly one ASV belonging to the genus Candidatus Nitrosopelagicus) were mainly related to the imprint of high-salinity MW, while upper subsurface (≤100 m) archaeal assemblages (particularly some ASVs belonging to Marine Group II) were linked to protein-like DOM (aCDOM254). Conversely, both upper and lower subsurface bacterial assemblages were mainly linked to aCDOM254 (particularly ASVs belonging to Rhodobacteraceae, Cyanobacteria, and Flavobacteriaceae) and nitrite concentration (mainly members of Planctomycetes). Most importantly, our analysis unveiled depth-ecotypes, such as the ASVs MarG.II_1 belonging to the archaeal deep cluster (linked to FDOM-M) and MarG.II_2 belonging to the upper subsurface cluster (related to FDOM-T and aCDOM254). This result strongly suggests DOM-mediated vertical niche differentiation, with further implications for ecosystem functioning. Similarly, positive and negative co-occurrence relationships also suggested niche partitioning (e.g., between the closely related ASVs Thaum._Nit._Nit._Nit._1 and _2) and competitive exclusion (e.g., between Thaum._Nit._Nit._Nit._4 and _5), supporting the finding of non-randomly, vertically structured prokaryotic communities. Overall, differences between Archaea and Bacteria and among closely related ASVs were revealed in their preferential relationship with compositional changes in the DOM pool and environmental forcing. Our results provide new insights on the ecological processes shaping prokaryotic assembly and biogeography.