Significance: The pineal gland is dedicated to the production of melatonin. Submammalian pineal glands can also detect light, and the retinas of many species can make melatonin. From this finding and others, it is seems that both tissues evolved from a common ancestral photodetector. A key factor driving their independent evolution may have been the evolution of melatonin synthesis and more specifically, the timezyme, a form of arylalkylamine N -acetyltransferase (AANAT) that plays a key role in controlling rhythmic production of melatonin. The current report indicates that the timezyme evolved from a primitive form of AANAT over 500 Mya in chordate evolution through a process of gene duplication followed by rapid neofunctionalization and that it was not a posthoc acquisition.