Understanding processes responsible for shaping biodiversity patterns on continental margins is an important requirement for comprehending anthropogenic impacts in these environments and further management of biodiversity. Continental margins perform crucial functions linked to key ecological processes which are mainly structured by surface primary productivity and particulate organic matter flux to the seafloor, but also by heterogeneity in seafloor characteristics. However, to what extent these processes control local and regional biodiversity remains unclear. In this study, two isobathic parallel transects located at the shelf break (300-400 m) and upper slope (1000 m) of the western Iberian margin were used to test how food input and sediment heterogeneity affect nematode diversity independently from the spatial factors geographical distance and water depth. We also examined the potential role of connectedness between both depth transects through molecular phylogenetic analyses. Regional generic diversity and turnover were investigated at three levels: within a station, between stations from the same depth transect, and between transects. High variability in food availability and high sediment heterogeneity at the shelf-break transect were directly linked to high diversity within stations and higher variation in community structure across stations compared to the upper slope transect. Contrastingly, environmental factors (food availability and sediment) did not vary significantly between stations located at the upper slope, and this lack of differences were also reflected in a low community turnover between these deeper stations. Finally, differences in nematode communities between both transects were more pronounced than differences within each of the isobathic transects, but these changes were paralleled by the previously mentioned environmental changes. These results suggest that changes in community structure are mainly dictated by environmental factors rather than spatial differences at the western Iberian margin. Furthermore, phylogenetic relationships revealed no evidence for depth-endemic lineages, indicating regular species interchanges across different depths.