Endophytic bacteria are nearly ubiquitously present in the internal tissues of plants, and some endophytes can promote plant growth. In this study, we sampled the roots of four ancestral species of sugarcane (two genotypes per species) and two sugarcane cultivars, and used 16S rRNA and nifH gene sequencing to characterize the root endophytic bacterial communities and diazotroph diversity. A total of 7,198 operational taxonomic units (OTUs) were detected for the endophytic bacteria community. The endophytic bacterial communities exhibited significantly different α- and β-diversities. From the 202 detected families in the sugarcane roots, a core microbiome containing 13 families was identified. The nifH gene was successfully detected in 9 of 30 samples from the four sugarcane species assayed, and 1,734 OTUs were merged for endophytic diazotrophs. In the tested samples, 43 families of endophytic diazotrophs were detected, and six families showed differences across samples. Among the 20 most abundant detected genera, 10 have been reported to be involved in nitrogen fixation in sugarcane. These findings demonstrate the diversity of the microbial communities in different sugarcane germplasms and shed light on the mechanism of biological nitrogen fixation in sugarcane.