The intensity and direction of sexual selection is intricately linked to the social and ecological context. Theory predicts that male-biased operational sex ratios (OSR) and high population density should skew resource and mate monopolization toward few successful males, thereby intensifying sexual selection on males. Here, we studied how the mating system of the promiscuous and strongly sexually dimorphic fruit fly Drosophila prolongata responds to changes in the OSR and population density. We recorded groups of flies over five days and quantified territory occupancy, mating success, and competitive fertilization success. Although general indices of the intensity of sexual selection supported theoretical predictions, realized selection on morphological traits did not. Rather, we found selection on these traits to intensify under high density, but also under even as opposed to male-biased OSRs. Larger and more territorial males achieved higher mating success, but only under even OSRs. Similarly, competitive fertilization success, mainly determined by sperm precedence, was biased toward large males only under even OSRs. Finally, our combined results support a shift in the mating system from territorial contest competition to scramble competition under male-biased OSRs and potentially at low density, where there was no clear contribution of the measured traits to reproductive success. Our study emphasizes the limitations of traditional selection metrics and the role of the socio-ecological context in predicting adaptation to a changing environment.