Soil bacteria typically coexist with close relatives generating widespread phylogenetic clustering. This has been ascribed to the abiotic filtering of organisms with shared ecological tolerances. Recent theoretical developments suggest that competition can also explain the phylogenetic similarity of coexisting organisms by excluding large low-competitive clades. We propose that combining the environmental patterns of traits associated with abiotic stress tolerances or competitive abilities with phylogeny and abundance data, can help discern between abiotic and biotic mechanisms underlying the coexistence of phylogenetically related bacteria. We applied this framework in a model system composed of interspersed habitats of highly contrasted productivity and comparatively dominated by biotic and abiotic processes, i.e. the plant patch-gap mosaic typical of drylands. We examined the distribution of 15 traits and 3290 bacterial taxa in 28 plots. Communities showed a marked functional response to the environment. Conserved traits related to environmental stress tolerance (e.g. desiccation, formation of resistant structures) were differentially selected in either habitat, while competition related traits (e.g. organic C consumption, formation of nutrient-scavenging structures) prevailed under high resource availability. Phylogenetic clustering was stronger in habitats dominated by biotic filtering, suggesting that competitive exclusion of large clades might underlie the ecological similarity of co-occurring soil bacteria.