Tryptophan decarboxylase (TDC) is the rate-limiting enzyme in the biosynthesis of melatonin and plays a crucial role in melatonin production in plants. Melatonin (MT), a multifunctional indoleamine compound, plays a pivotal role in plant responses to abiotic stress. Substantial evidence has demonstrated that MT can significantly enhance plant tolerance to drought stress. However, the molecular mechanisms underlying MT-mediated drought stress responses in plants remain unclear. This study systematically analyzed the evolutionary relationships of the TDC gene family in four cotton species using bioinformatics approaches, including phylogenetic analysis, chromosomal localization, gene structure, conserved motifs, cis-acting elements, synteny, and expression patterns. Functional characterization of GhTDC5 in Gossypium hirsutum was performed using virus-induced gene silencing (VIGS), with the following key findings: gene silencing efficiency reached 67.5%, leading to a significant 50.31% reduction in melatonin content. Under drought stress, silenced plants exhibited a 46.56% decrease in leaf water content, 23.01% reduction in chlorophyll content, and more severe wilting symptoms compared to controls. Impaired antioxidant system: significant decreases in peroxidase (POD) and superoxide dismutase (SOD) activities as well as proline (Pro) content, along with increased malondialdehyde (MDA) and ROS accumulation. Exogenous melatonin treatment effectively scavenged superoxide anions and alleviated drought stress. The results demonstrate that GhTDC5 plays a crucial role in cotton drought resistance by regulating melatonin biosynthesis. This study not only elucidates the evolutionary characteristics of the TDC gene family but also provides important theoretical foundations and candidate genes for drought-resistant cotton breeding.