Role of Melatonin in Circadian Rhythm
This is a quite complicated question, as melatonin has quite a range of effects on the cells. First, melatonin binds to three different melatonin receptors, which are found in a wide variety of tissues or organs including brain and retina, cardiovascular system, liver and gallbladder, intestine, kidney, immune cells, adipocytes, prostate and breast epithelial cells, ovary/granulosa cells, myometrium, and skin.

Two of the receptors a G-protein coupled receptors (GPCR), the MT1 and MT2 receptors. The third is a quinone reductase called QR2.

For more details, see this papers:


Melatonin receptors in humans: biological role and clinical
relevance.
Melatonin receptors and their regulation: biochemical and structural
mechanisms.


The role of melatonin is pretty broad, see the figure (from this article:"Melatonin: Nature's most versatile biological signal?")



The receptors transport the outside chemical signal (the melatonin) to the inside and activate (or repress) a number of different signal transduction pathways. See the figure below (taken from Qiagen): 



This includes MAP-Kinase pathways, proteinkinase C, IP3, adenyl cyclase and so on. This is quite complicated and I recommend reading some of the following articles if you are interested in a deeper insight. Finally these signals are transmitted into the nucleus and result in a changed gene regulation/expression.


Melatonin receptors, heterodimerization, signal transduction and
binding sites: what's new?
Physiological effects of melatonin: role of melatonin receptors and
signal transduction pathways.