Soil microorganisms, including prokaryotes and eukaryotes, represent a large fraction of global terrestrial biodiversity. These organisms and their microbiomes play critical roles in ecosystem functioning and services and are essential to soil health. Soil biodiversity is governed by above-ground and below-ground factors, which create specific habitat conditions that structure soil communities. However, the compounded effects of such environmental drivers are often understudied, thus limiting our understanding of processes governing soil biodiversity, especially in desert habitats. Here we show that above- and below-ground factors shape prokaryotic and microeukaryotic communities, but these environmental factors do not appear to structure invertebrate-associated microbiomes. By integrating metabarcoding and morphological datasets, we found that soil compactness is a major factor structuring prokaryote and microeukaryote assemblages and influences the abundance of genes involved in nutrient cycling and organic matter decomposition. Despite having lower nitrogen levels, compacted soils displayed significantly higher alpha-diversity than uncompacted habitats across datasets. Different bacterial clades were enriched within specific nematode lineages (Plectids and Tylenchids) highlighting potentially new species-specific nematode-associated taxa. The data suggests that nematode microbiomes are less impacted by the same environmental drivers of the soil bacterial community and respond to microscale variations among sampling sites. The prevalence of functionally diverse invertebrate-associated bacteria (Mycobacterium) in the nematode microbiome suggests that these microbial communities benefit the host. Our findings highlight the importance of assessing above- and below-ground effects to elucidate patterns of microbial community assembly in terrestrial habitats, and how fine-scale analyses are critical for understanding patterns of host-associated microbiomes.