Abstract Aim Dispersal and environmental gradients shape marine microbial communities, yet the relative importance of these factors across taxa with distinct sizes and dispersal capacity in different ocean layers is unknown. Here, we report a comparative analysis of surface and deep ocean microbial beta diversity and examine how these patterns are tied to oceanic distance and environmental gradients. Location Tropical and subtropical oceans (30°N–40°S). Time period 2010–2011. Major taxa studied Prokaryotes and picoeukaryotes (eukaryotes between 0.2 and 3 μm). Methods Beta diversity was calculated from metabarcoding data on prokaryotic and picoeukaryotic microbes collected during the Malaspina expedition across the tropical and subtropical oceans. Mantel correlations were used to determine the relative contribution of environment and oceanic distance driving community beta diversity. Results Mean community similarity across all sites for prokaryotes was 38.9% in the surface and 51.4% in the deep ocean, compared to mean similarity of 25.8 and 12.1% in the surface and deep ocean, respectively, for picoeukaryotes. Higher dispersal rates and smaller body sizes of prokaryotes relative to picoeukaryotes likely contributed to the significantly higher community similarity for prokaryotes compared with picoeukaryotes. The ecological mechanisms determining the biogeography of microbes varied across depth. In the surface ocean, the environmental differences in space were a more important factor driving microbial distribution compared with the oceanic distance, defined as the shortest path between two sites avoiding land. In the deep ocean, picoeukaryote communities were slightly more structured by the oceanic distance, while prokaryotes were shaped by the combined action of oceanic distance and environmental filtering. Main conclusions Horizontal gradients in microbial community assembly differed across ocean depths, as did mechanisms shaping them. In the deep ocean, the oceanic distance and environment played significant roles driving microbial spatial distribution, while in the surface the influence of the environment was stronger than oceanic distance.