Streptococcus agalactiae has different virulence factors, from which the capsule has the most significant role in the pathogenesis of this organism. We aimed to investigate the distribution of more prevalent capsular genes among different Random Amplified Polymorphic DNA (RAPD) types of S. agalactiae isolated from pregnant women. A total of 106 isolates were collected from 420 vaginal and rectal swabs obtained from pregnant women. The specimens were transferred using Todd Hewitt Broth and were cultured on a blood agar containing antibiotics. The S. agalactiae isolates were identified by the standard microbiological and biochemical tests. The genomic DNAs of S. agalactiae isolates were extracted using an extraction kit. Then, the PCR method was used to detection of the capsular genes. Moreover, The RAPD PCR was used to genotyping of the isolates. The colonization rate of the pregnant women was 25.23%, and there was a statistically significant correlation between the weeks of gestation and the probability of colonization (p-value < 0.05). Also, 31 (29.24%) and 18 (16.98%) pregnant women had a history of abortion and membrane rupture, respectively. In addition, 20 (18.86%), 32 (30.18%), 4 (3.77%), and 6 (5.66%) isolates carried genes encoding capsular types Ia, Ib, III, and V, respectively. None isolates had the type II capsular gene, and other 44 isolates were non-typeable. Nine clones (clusters) of S. agalactiae were observed in the present study with 70% similarity, and 53 different types were identified among the isolates. Except for capsular types III and V that belonged to clones 3, 5, 7, and 9, other capsular types were detected in different RAPD types. We found that the capsular types Ib and Ia were predominant among pregnant women in this area, indicating their significance for vaccine designation. Also, our isolates showed a lower genotypic diversity in RAPD typing. This may be due to the same sources of most isolates.