Vestigial organs are historical echoes of past phenotypes. Determining whether a specific organ constitutes a functional or vestigial structure can be a challenging task, given that distinct levels of atrophy may arise between and within lineages. The mammalian pineal gland, an endocrine organ involved in melatonin biorhythmicity, represents a classic example, often yielding contradicting anatomical observations. In Xenarthra (sloths, anteaters and armadillos), a peculiar mammalian order, the presence of a distinct pineal organ was clearly observed in some species (i.e. Linnaeus's two-toed sloth) but undetected in other closely related species (i.e. brown-throated sloth). In the nine-banded armadillo, contradicting evidence supports either functional or vestigial scenarios. Thus, to untangle the physiological status of the pineal gland in Xenarthra, we used a comparative genomics approach to investigate the evolution of the gene hub responsible for melatonin synthesis and signaling. We show that both synthesis and signaling compartments are eroded and were lost independently. Additionally, by expanding our analysis to 157 mammal genomes we offer a comprehensive view showing that species with very distinctive habitats and lifestyles have convergently evolved a similar phenotype: Cetacea, Pholidota, Dermoptera, Sirenia and Xenarthra. Our findings suggest that the recurrent inactivation of melatonin genes correlates with pineal atrophy, and endorse the use of genomic analyses to ascertain the physiological status of suspected vestigial structures.