Cadmium (Cd), a non-essential element for plant, is a ubiquitous and highly toxic heavy metal, seriously endangering agricultural production and human health. As a nonedible economic crop, cotton (Gossypium hirsutum L.) has great potential in remediation of Cd contaminated soil, but its underlying mechanism is still unknown. Melatonin (MT), as a plant growth regulator, is involved in alleviating Cd toxicity in some plants, but the molecular mechanisms of MT-mediated Cd detoxification in cotton are largely unknown. This study investigated the possible molecular mechanisms of the MT-mediated Cd detoxification in cotton seedlings by comparative transcriptomic and metabolomic analyses. The results showed that the cotton seedlings were dwarfed and the leaves were wilted and yellow under Cd stress. The application of 50 µmol L−1 MT significantly increased the superoxide dismutase (SOD) activity and malondialdehyde (MDA) content under Cd stress, but 100 µmol L−1 MT significantly decreased SOD activity, while increased ascorbate peroxidase (APX) activity significantly. The addition of 100 μmol L−1 MT significantly increased Cd concentration in the shoots and roots under Cd stress. RNA-seq analysis showed that 5573, 7105, 7253, 25, 198, 9 up-regulated and 6644, 7192, 7404, 9, 59, 0 down-regulated differentially expressed genes (DEGs) were identified in the comparisons of CK vs T1, CK vs T2, CK vs T3, T1 vs T2, T1 vs T3 and T2 vs T3, respectively. It was revealed that MT promoted the expression of certain related genes under Cd stress, and the effect of 100 µmol L−1 MT was better. Moreover, UPLC-MS/MS widely targeted metabolites analyses showed that 195, 150, 150, 12, 24, 59 up-regulated and 16, 11, 23, 38, 127, 66 down-regulated differentially accumulated metabolites (DAMs) were changed in the CK vs T1, CK vs T2, CK vs T3, T1 vs T2, T1 vs T3 and T2 vs T3, respectively. It was revealed that MT induced the synthesis of alkaloids and flavonoids, and inhibited or reduced the synthesis of lipids, amino acids and their derivatives. The comprehensive analyses of transcriptomic and metabolic data showed that 33 DEGs and 4 DAMs, 46 DEGs and 16 DAMs, and 1 DEGs and 1 DAMs were dominantly involved in the pathways of valine, leucine and isoleucine degradation, ABC transporter, alpha-linolenic acid metabolism, respectively. It was revealed that there were three major mechanisms involved in MT-mediated Cd detoxification in cotton, including the enhancement of antioxidant capacity regulated by APX, flavonoids and alkaloids; accumulation of secondary metabolites related to Cd chelation, such as amino acids and derivatives; and regulation of cadmium ion transportation, such as ABC transporter activation. In conclusion, this study provides new insights into the MT-mediated Cd stress response.