AbstractEphemeral plants are important part of the vegetation maintaining Gurbantünggüt Desert‐oasis ecotone stability. Studying the response characteristics of root‐associated bacteria of ephemeral plants to soil habitats is of great significance for understanding the adaptability of plants and maintaining ecotone stability. In this study, physicochemical analysis and 16 S sequencing technology were used to analyse the diversity, structure, function, and driving factors of rhizosphere and root‐endophytic bacteria of ephemeral plants in aeolian soil and grey desert soil. The results showed differences in the rhizosphere soil properties and root nutrient content between the two habitat soils. The Shannon index of the rhizosphere bacteria in the grey desert soil was higher than that in the aeolian soil, whereas the Shannon and ACE indices of the endophytic bacteria were lower than those in the aeolian soil. Soil type caused evident changes in the relative abundance and community structure of the rhizosphere and endophytic bacteria. PICRUSt function prediction showed that energy metabolism, carbohydrate metabolism, amino acid metabolism, replication and repair, and membrane transport were the main functional categories of rhizosphere and endophytic bacteria in the two soils. The rhizosphere and endophytic bacteria of ephemeral plants were closely related to soil factors. Soil water content, electrical conductivity (EC), total phosphorus, total potassium, and nitrogen/phosphorus ratio were the key factors affecting the rhizosphere bacterial community structure and function. The key factors affecting the root‐endophytic bacterial community structure and function were the pH, EC, total phosphorus, ammonium nitrogen, available potassium, carbon/phosphorus ratio, and root phosphorus. This study revealed the community structure, functions and driving factors of root‐associated bacteria in ephemeral plants grown in different soils. These findings have significance for future studies on the bacterial metabolic function of ephemeral plants and provide references for vegetation protection and restoration in different soils of the ecotone.