While physiological levels of glucocorticoids are required to ensure proper functions of the body, consistently high levels may engender several deleterious consequences. We have previously shown an increase in the activity of the hypothalamic‐pituitary‐adrenal (HPA) axis in rats fed sucrose‐rich diets (SRD). The main goal of this study was to analyze the processes involved in the modulation of the pituitary production of ACTH by SRD, and to test melatonin as a possible therapeutic agent for the prevention of the HPA axis dysfunction. Male Wistar rats were fed standard chow and either SRD (30% sucrose in the drinking water) or plain water for three weeks. Melatonin was administered as subcutaneous pellets. Results showed that SRD treatment induced an increase in systemic ACTH and corticosterone levels and a decrease in melatonin levels. In the pituitary gland, we also detected an increase in the expression levels of proopiomelanocortin (POMC) that was accompanied by increased levels of: lipoperoxides, nitro‐tyrosine modified proteins, catalase, heme oxygenase‐1, interleukin‐1β mRNA, and by an increase in the tissue number of inflammatory cells (F4/80 and Iba‐1 positive cells). Melatonin treatment prevented all these systemic and pituitary changes as well as the increase in POMC expression induced by incubation of AtT‐20 corticotrophs with conditioned media obtained from stimulated macrophages. In conclusion, stimulation of POMC/ACTH production in rats fed a SRD could involve the generation of oxidative stress and inflammation in the pituitary gland. Melatonin treatment prevented these effects and normalized the activity of the HPA axis.