In China, excessive use of nitrogen fertilizers in glasshouses leads to nitrate accumulations in soil and plants, which then limits productivity. Melatonin, an evolutionarily highly conserved molecule, has a wide range of functions in plants. We analyzed the effects of melatonin pretreatment on the growth, mineral nutrition, and nitrogen metabolism in cucumber (Cucumis sativus L. "Jin You No. 1") when seedlings were exposed to nitrate stress. An application of 0.1 mmol/L melatonin significantly improved the growth of plants and reduced their susceptibility to damage due to high nitrate levels (0.6 mol/L) during the ensuing period of stress treatment. Although excess nitrate led to an increase in the concentrations of nitrogen, potassium, and calcium, as well as a decrease in levels of phosphorus and magnesium, exogenous melatonin generally had the opposite effect except for a further rise in calcium concentrations. Pretreatment also significantly reduced the accumulations of nitrate nitrogen and ammonium nitrogen and enhanced the activities of enzymes involved in nitrogen metabolism. Expression of Cs-NR and Cs-GOGAT, two genes that function in that metabolism, was greatly down-regulated when plants were exposed to 0.6 mol/L nitrate, but was up-regulated in plants that had received the 0.1 mmol/L melatonin pretreatment. Our results are the first evidence that melatonin has an important role in modulating the composition of mineral elements and nitrogen metabolism, thereby alleviating the inhibitory effect on growth normally associated with nitrate stress.