Melatonin is a naturally occurring neuro-hormone that is secreted by the pineal gland in the brain. When released from the pineal gland, melatonin causes drowsiness and a decrease in core body temperature. The levels of melatonin rise throughout the evening hours and peak in the middle of the night (opposite to cortisol levels). That is if there is relative darkness. Even ordinary room light (approximately 100 lux) can cause a rapid suppression in melatonin. This is why sleep doctors are always telling people, at least people who have trouble falling asleep, that they should avoid reading in bed.

Research suggests that melatonin not only helps us sleep and maintain our 24-hour clock, but that it acts as a powerful antioxidant that destroys cancerous cells. It may also boost immunity and help in weight loss. The antioxidant properties are thought to explain why night shift workers have a higher rate of cancer. Night after night they suppress their melatonin by staying up and being exposed to light.
Melatonin has been studied as a sleep promoting agent in doses ranging from 0.3 mg to 80 mg and the results are often disappointing. There are a few hypotheses why that is the case. First, melatonin is sold as a dietary supplement in the US and you can’t rely on the dose really being what the bottle says it is. Many European countries such as Germany regulate their dietary supplements as strictly as they do their pharmaceuticals. In fact, Germany considers melatonin a prescription medication. Second, the timing of the dosing of melatonin when treating insomnia has not been firmly established.
The drug can be administered orally as pills, as sublingual (under the tongue) and as transdermal (skin) patches.

One should also keep in mind that certain medications such as beta blockers and anti-depressants can suppress melatonin levels. Although the effectiveness of melatonin is questionable, it is generally considered safe in adults. Common side effects include morning grogginess, headache, vivid dreaming.
Melatonin agonists (drugs that act on melatonin receptors in the brain), like Ramelteon (and the soon to come Tasimelteon) are more effective than melatonin itself. They can only be obtained with a prescription though.
Reference: Dr. Lisa Shives’ Sleep Blog
