Our understanding of the evolutionary significance of ectoparasites in natural communities is limited by a paucity of information concerning the mechanisms and heritability of resistance to this ubiquitous and diverse assemblage of organisms. Here, we report the results of artificial selection for increasing ectoparasite resistance in replicate lines of Drosophila melanogaster derived from a field-fresh population. Resistance, as ability to avoid infestation by naturally occurring Gamasodes queenslandicus mites, increased significantly in response to selection, and realized heritability (s.e.) was estimated to be 0.11 (0.0090). Ability to deploy energetically expensive bursts of flight from the substrate was a main mechanism of resistance that responded to selection, aligning with previously documented metabolic costs of fly behavioral defenses. Host body size, which affects parasitism rate in some fly-mite systems, was not shifted by selection. In contrast, resistant lines expressed significant reductions in larva-to-adult survivorship with increasing toxic (ammonia) stress, identifying an environmentally modulated pre-adult cost of resistance. Flies resistant to G. queenslandicus were also more resistant to a different mite, Macrocheles subbadius, suggesting that we documented genetic variation and a pleiotropic cost of broad-spectrum behavioral immunity against ectoparasites. This study demonstrates significant evolutionary potential of an ecologically important trait.