In many animal species, males do not seek females directly but instead locate and defend sites that contain spatially or temporally limited resources essential to female survival and reproduction. Resident males that successfully repel conspecific rivals can mate with females attracted to these resources. In theory, increasing resource value increases harem size and thus increases the opportunity (I mates ) for and strength of sexual selection on traits crucial to male resource-holding potential and mating success. I experimentally tested this hypothesis in the field using the Wellington tree weta, Hemideina crassidens (Orthoptera: Tettigonioidea: Anostostomatidae), a sexually dimorphic insect in which males use their enlarged mandibles as weapons in male--male contests over access to females sheltering in tree cavities (galleries). By manipulating gallery size, I showed that, compared with smaller galleries, larger galleries housed larger harems. Variation in gallery size was an important determinant of I mates , but contrary to expectation, greater opportunity existed in small galleries compared with large galleries. As predicted, male weapon size was under stronger directional selection in large galleries because the fitness benefits were greater under these conditions compared with small galleries. My results help explain the positive association between average weapon size and average gallery size observed within and among tree weta populations in New Zealand. Copyright 2008, Oxford University Press.