Nematophagous fungi can trap and capture nematodes and other small invertebrates. This unique ability has made them ideal organisms from which to develop biological control agents against plant- and animal-parasitic nematodes. However, effective application of biocontrol agents in the field requires a comprehensive understanding about the ecology and population genetics of the nematophagous fungi in natural environments. Here, we genotyped 228 strains of the nematode-trapping fungus Arthrobotrys oligospora using 12 single nucleotide polymorphic markers located on eight random DNA fragments. The strains were from different ecological niches and geographical regions from China. Our analyses identified that ecological niche separations contributed significantly, whereas geographic separation contributed relatively little to the overall genetic variation in our samples of A. oligospora. Interestingly, populations from stressful environments seemed to be more variable and showed more evidence for recombination than those from benign environments at the same geographic areas. We discussed the implications of our results to the conservation and biocontrol application of A. oligospora in agriculture and forestry.