A hormone that’s made by the pineal gland in the brain, melatonin helps control your daily sleep-wake cycles. Your body’s internal clock (also known as your circadian rhythm) influences how much melatonin the pineal gland makes, and so does the amount of light that you’re exposed to each day. Typically, melatonin levels start to rise in the mid-to-late evening, after the sun has set. They stay elevated for most of the night while you’re in the dark. Then, they drop in the early morning as the sun rises, causing you to awaken.
https://sleep.org/articles/melatonin/