Elevational gradients of biodiversity have been widely investigated, and yet a clear interpretation of the biotic and abiotic factors that determine how species richness varies with elevation is still elusive. In mountainous landscapes, habitats at different elevations are characterized by different areal extent and connectivity properties key drivers of biodiversity, as predicted by metacommunity theory. However, most previous studies directly correlated species richness to elevational gradients of potential drivers, thus neglecting the interplay between such gradients and the environmental matrix. Here, we investigate the role of geomorphology in shaping patterns of species richness. We develop a spatially explicit zero-sum metacommunity model where species have an elevation-dependent fitness and otherwise neutral traits. Results show that ecological dynamics over complex terrains lead to the null expectation of a hump-shaped elevational gradient of species richness, a pattern widely observed empirically. Local species richness is found to be related to the landscape elevational connectivity, as quantified by a newly proposed metric that applies tools of complex network theory to measure the closeness of a site to others with similar habitat. Our theoretical results suggest clear geomorphic controls on elevational gradients of species richness and support the use of the landscape elevational connectivity as a null model for the analysis of the distribution of biodiversity.