Mechanisms of resistance to pathogens and parasites are thought to be costly and thus to lead to evolutionary trade‐offs between resistance and life‐history traits expressed in the absence of the infective agents. On the other hand, sexually selected traits are often proposed to indicate “good genes” for resistance, which implies a positive genetic correlation between resistance and success in sexual selection. Here I show that experimental evolution of improved resistance to the intestinal pathogen Pseudomonas entomophila in Drosophila melanogaster was associated with a reduction in male sexual success. Males from four resistant populations achieved lower paternity than males from four susceptible control populations in competition with males from a competitor strain, indicating an evolutionary cost of resistance in terms of mating success and/or sperm competition. In contrast, no costs were found in larval viability, larval competitive ability and population productivity assayed under nutritional limitation; together with earlier studies this suggests that the costs of P. entomophila resistance for nonsexual fitness components are negligible. Thus, rather than indicating heritable pathogen resistance, sexually selected traits expressed in the absence of pathogens may be sensitive to costs of resistance, even if no such costs are detected in other fitness traits.