The black pineleaf scale insect has haploid males and diploid females. Ratios of males to females late in development ranged from 0.005 to 0.320 among insect subpopulations that were infesting different host trees. Demes well adapted to an individual ponderosa pine had a higher proportion of males than did demes that were poorly adapted to the host. Ratios of males to females rose in successive annual samples as natural selection increased insect adaptation. Gene flow between demes on different host trees produced predictable changes in the sex ratio.