Theory predicts that sexual selection should aid adaptation to novel environments, but empirical support for this idea is limited. Pathogens are a major driver of host evolution and, unlike abiotic selection pressures, undergo epidemiological and co‐evolutionary cycles with the host involving adaptation and counteradaptation. Because of this, populations harbor ample genetic variation underlying immunity and the opportunity for sexual selection based on condition‐dependent “good genes” is expected to be large. In this study, we evolved populations of Drosophila melanogaster in a 2‐way factorial design manipulating sexual selection and pathogen presence, using a gram‐negative insect pathogen Pseudomonas entomophila, for 14 generations. We then examined how the presence of sexual selection and the pathogen, as well as any potential interaction, affected the evolution of pathogen resistance. We found increased resistance to P. entomophila in populations that evolved under pathogen pressure, driven primarily by increased female survival after infection despite selection for resistance acting only on males over the course of experimental evolution. This result suggests that the genetic basis of resistance is in part shared between the sexes. We did not find any evidence of sexual selection aiding adaptation to pathogen, however, a finding contrary to the predictions of “good genes” theory. Our results therefore provide no support for a role for sexual selection in the evolution of immunity in this experimental system.