In many species, the natural distribution of material resources important for reproduction can profoundly impact reproductive success among individuals and, hence, the opportunity and intensity of sexual selection. Here, we report on a field-based experiment investigating the effects of nest aggregation on sexual selection in a fish, the sand goby Pomatoschistus minutus. We found that the distribution of potential nests (sparse versus aggregated nest treatments) affected patterns of nest colonization and reproductive success. Specifically, in the treatment with aggregated nesting resources, a greater proportion of nests remained unoccupied by sand goby males. Although the size of nesting males did not differ between treatments, eggs accumulated more rapidly when nests were sparsely distributed. We found that the opportunity for selection decreased over time with the accumulation of eggs in the nests in both the aggregated and sparse treatments. Moreover, the effect of male size on reproductive success was influenced by an interaction between nest distribution and time, with the selection gradient being highest right after nest colonization when nests were aggregated, while the opposite pattern was observed in the sparse nest treatment. Such findings highlight the vital role that environmental and social factors can play in determining the importance of male phenotypic traits (in this case, male size). More broadly, our results also underscore how the natural distribution of resources, both in space and time, can impact the strength of sexual selection acting on wild animal populations.