A link between reproductive hormones and melanoma has long been suspected, and has been examined for numerous hormonal exposures, but the association between in-vitro fertilization (IVF) and melanoma has not been studied in depth. We used whole-population linked hospital and registry data to carry out a cohort study of women aged 20–44 years seeking hospital investigation and treatment for infertility in Western Australia from 1982 to 2002 with follow-up to 2010. The cohort comprised a total of 21 604 women followed for an average of 17.2 years. Of these, 7524 had IVF treatment, 14 870 gave birth and 149 women were diagnosed with an incident invasive melanoma. Using Cox regression analysis, we estimated hazard ratios (HRs) for melanoma associated with IVF and parity. Women who had IVF and gave birth had an increased rate of invasive melanoma compared with women who had IVF and remained nulliparous (HR 3.61; 95% confidence interval 1.79–7.26). There was little or no increase in the rate of invasive melanoma associated with giving birth in women who had non-IVF infertility treatment (HR 1.39; 95% confidence interval 0.88–2.20). These results suggest an association between reproductive factors and melanoma in the subgroup of women undergoing IVF treatment.