Variations in diabetic phenotypes are caused by complex interactions of genetic effects, environmental factors, and the interplay between the two. We tease apart these complex interactions by examining genome-wide genetic and epigenetic effects on diabetes-related traits among different sex, diet, and sex-by-diet cohorts in a Mus musculus model. We conducted a genome-wide scan for quantitative trait loci that affect serum glucose and insulin levels and response to glucose stress in an F-16 Advanced Intercross Line of the LG/J and SM/J intercross (Wustl:LG,SM-G16). Half of each sibship was fed a high-fat diet and half was fed a relatively low-fat diet. Context-dependent genetic (additive and dominance) and epigenetic (parent-of-origin imprinting) effects were characterized by partitioning animals into sex, diet, and sex-by-diet cohorts. We found that different cohorts often have unique genetic effects at the same loci, and that genetic signals can be masked or erroneously assigned to specific cohorts if they are not considered individually. Our data demonstrate that the effects of genes on complex trait variation are highly context-dependent and that the same genomic sequence can affect traits differently depending on an individual's sex and/or dietary environment. Our results have important implications for studies of complex traits in humans.