Aluminum (Al) toxicity is the most common factor limiting the growth of alfalfa in acidic soil conditions. Melatonin (MT), a significant pleiotropic molecule present in both plants and animals, has shown promise in mitigating Al toxicity in various plant species. This study aims to elucidate the underlying mechanism by which melatonin alleviates Al toxicity in alfalfa through a combined physiological and transcriptomic analysis. The results reveal that the addition of 5 μM melatonin significantly increased alfalfa root length by 48% and fresh weight by 45.4% compared to aluminum treatment alone. Moreover, the 5 μM melatonin application partially restored the enlarged and irregular cell shape induced by aluminum treatment, resulting in a relatively compact arrangement of alfalfa root cells. Moreover, MT application reduces Al accumulation in alfalfa roots and shoots by 28.6% and 27.6%, respectively. Additionally, MT plays a crucial role in scavenging Al-induced excess H2O2 by enhancing the activities of superoxide dismutase (SOD), peroxidase (POD), and catalase (CAT), consequently reducing malondialdehyde (MDA) levels. More interestingly, the RNA-seq results reveal that MT application significantly upregulates the expression of xyloglucan endotransglucosylase/hydrolase (XTH) and carbon metabolism-related genes, including those involved in the glycolysis process, as well as sucrose and starch metabolism, suggesting that MT application may mitigate Al toxicity by facilitating the binding of Al to the cell walls, thereby reducing intracellular Al accumulation, and improving respiration and the content of sucrose and trehalose. Taken together, our study demonstrates that MT alleviates Al toxicity in alfalfa by reducing Al accumulation and restoring redox homeostasis. These RNA-seq results suggest that the alleviation of Al toxicity by MT may occur through its influence on cell wall composition and carbon metabolism. This research advances our understanding of the mechanisms underlying MT’s effectiveness in mitigating Al toxicity, providing a clear direction for our future investigations into the underlying mechanisms by which MT alleviates Al toxicity in alfalfa.