Sperm competition is a crucial aspect of male reproductive success in many species, including
Drosophila melanogaster,
and seminal fluid proteins (Sfps) can influence sperm competitiveness. However, the combined effect of environmental and genotypic variation on sperm competition gene expression remains poorly understood. Here, we used
Drosophila
Genetic Reference Panel (DGRP) inbred lines and manipulated developmental population density (i.e. larval density) to test the effects of genotype, environment and genotype-by-environment interactions (GEI) on the expression of the known sperm competition genes
Sex Peptide
,
Acp36DE
and
CG9997
. High larval density resulted in reduced adult body size, but expression of sperm competition genes remained unaffected. Furthermore, we found no significant GEI but genotypic effects in the expression of
SP
and
Acp36DE
. Our results also revealed GEI for relative competitive paternity success (second male paternity; P2), with genes’ expression positively correlated with P2. Given the effect of genotype on the expression of genes, we conducted a genome-wide association study (GWAS) and identified polymorphisms in putative
cis
-regulatory elements as predominant factors regulating the expression of
SP
and
Acp36DE
. The association of genotypic variation with sperm competition outcomes, and the resilience of sperm competition genes’ expression against environmental challenges, demonstrates the importance of genome variation background in reproductive fitness.