Compromised pregnancies such as those associated with gestational diabetes mellitus, intrauterine growth retardation, preeclampsia, maternal undernutrition, and maternal stress may negatively affect fetal development. Such pregnancies may induce oxidative stress to the fetus and alter fetal development through the epigenetic process that may affect development at a later stage. Melatonin is an oxidant scavenger that reverses oxidative stress during the prenatal period. Moreover, the role of melatonin in epigenetic modifications in the field of developmental programming has been studied extensively. Here, we describe the physiological function of melatonin in pregnancy and discuss the roles of melatonin in fetal programming in compromised pregnancies, focusing on its involvement in redox and epigenetic mechanisms.