The root microbiota plays a crucial role in assisting the plant host in combating various biotic and abiotic stresses, notably drought, which poses a significant threat to global food security. Despite extensive efforts to understand the shifts in rhizosphere and endosphere bacteriomes, there remains a gap in comprehending how drought stress influences the co-occurring network patterns within these compartments and their ecological functional potentials. To address this gap, a pot experiment was conducted with two treatments: continuous flooding as a control and drought treatment. Bulk soil, rhizosphere, and endosphere samples were collected and subjected to high-throughput sequencing and bioinformatics analysis. The results revealed that drought stress significantly reduced the rice biomass but increased the Shannon diversity index in both the rhizosphere and endosphere bacterial communities with no observable effect on richness across compartments. Additionally, drought treatment markedly altered the community structure and bacterial assemblages in these compartments, resulting in the specific enrichment of Actinobacteriota, Gemmatimonadetes, and Patescibacteria, while Bacteroidetes and Firmicutes were depleted in the rhizosphere and endosphere. Furthermore, drought heightened the complexity of the co-occurring networks and the proportions of positive links across all sampling compartments; this effect was accompanied by an increase in the number of connectors in the bulk soil and rhizosphere, as well as module hubs in the rhizosphere. Functional potential prediction indicated that drought stress significantly altered multiple potential ecological functions across all sampling compartments, particularly enriching functions related to the oxidation of sulfur, manganese, and hydrogen in the bulk soil, while functions associated with iron oxidation were significantly depleted in the rhizosphere. Overall, our results demonstrate that under drought stress, rice may specifically enrich certain bacterial taxa and enhance their positive interactions within its root system to improve adaptation.