Plant growth-promoting bacteria (PGPB) are a group of beneficial microorganisms that include 60 bacterial genera, such as Bacillus, Pseudomonas, and Burkholderia, which widely colonize plant leaves and soil, promote plant growth, and/or inhibit pathogen infection. However, the genetic factors underpinning adaptation of PGPB to plant leaves and soil remain poorly understood. In this study, we performed a comparative functional genome analysis approach to investigate the functional genes of 195 leaf-associated (LA) and 283 soil-associated (SA) PGPB strains and their roles in adapting to their environment, using 95 strains from other-associated (OA) environmental habitats with growth-promoting or antimicrobial functions as negative controls. Comparison analysis of the enrichment of nonredundant (NR) protein sequence databases showed that cytochrome P450, DNA repair, and motor chemotaxis genes were significantly enriched in LA PGPB strains related to environmental adaptation, while cell wall-degrading enzymes, TetR transcriptional regulatory factors, and sporulation-related genes were highly enriched in SA PGPB strains. Additionally, analysis of carbohydrate-active enzymes demonstrated that glycosyltransferases (GTs) and glycoside hydrolases (GHs) were abundant families in all PGPB strains, which is in favor of plant growth, and enriched in SA PGPB strains. Except for most Bacillus strains, SA PGPB genomes contained significantly more secondary metabolism clusters than LA PGPB. Most LA PGPB contained hormone biosynthesis genes, which may contribute to plant growth promotion, while SA PGPB harbored numerous carbohydrate and antibiotic metabolism genes. In summary, this study further deepens our understanding of the habitat adaptation and biocontrol characteristics of LA and SA PGPB strains. IMPORTANCE Plant growth-promoting bacteria (PGPB) are essential for the effectiveness of biocontrol agents in plant phyllosphere and rhizosphere. However, little is known about the ecological adaptation of PGPB to different habitats. In this study, comparative functional genome analysis of leaf-associated (LA), soil-associated (SA), and other-associated (OA) PGPB strains was performed. We found that genes related to the metabolism of hormones were enriched in LA PGPB. Carbohydrate and antibiotic metabolism genes were enriched in SA PGPB, which likely facilitated their adaptation to the plant growth environment. Our findings provide genetic insights on LA and SA PGPB strains' ecological adaptation and biocontrol characteristics.