An oral melatonin pharmaceutical dosage form that contains a sustained release dose of melatonin includes melatonin and an acid dispersed in a hydrogel-forming polymer matrix that combine after ingestion to form an acidic hydrogel containing the melatonin.