The effect of ecogeographical factors on genetic similarity was investigated among five populations of Onobrychis viciifolia (sainfoin, Fabaceae) in East-Azarbaijan, Iran using RAPDs and bulked DNA. A number of 10 individual plants were randomly selected from each population. A number of 10 primers were tested, among which five producing the maximum numbers of clear and reproducible bands were selected. RAPD patterns were repeated three times for each primer to ascertain the reproducibility. The genetic distance between populations was measured based on Nei's Genetic distance, and the genetic similarity among the populations was assessed using UPGMA dendrogram based on Nei's distance matrix. The five primers produced a total of 12 polymorphic bands. The percentage of the bands produced by each primers ranged from 16.7% to 25%. The largest and shortest genetic distances were detected between Bonab and Heris (0.4904) and Amand and Khosroshahr (0.0572), respectively. On the UPGMA dendrogram, two populations of Sarab and Heris were nested within one cluster, and Amand and Khosroshahr in another cluster, while Bonab was completely separated from all other populations. The similarity between these pairs of populations could be attributed to the ecological similarity, because Bonab and Heris populations were distributed in regions with high altitude with cold climate, while Amand and Khosroshahr populations grew on salinity soils with warm climate. Separation of Bonab population from all others could be due to growing on the high saline soils and also being geographically very distant. Our results showed that RAPDs were capable to detect ecotypes of Sainfoin, and that they were affected by ecological factors.