Milk fat content is an important criterion for assessing milk quality and is one of the main target traits of dairy cattle breeding. Recent studies have shown the importance of melatonin in regulating lipid metabolism, but the potential effects of melatonin on milk fat synthesis in bovine mammary epithelial cells (BMECs) remain unclear. Here, we showed that melatonin supplementation at 10 μmol/L significantly downregulated the mRNA expression of lipid metabolism–related genes and resulted in lower lipid droplet formation and triglyceride accumulation. Moreover, melatonin significantly upregulated melatonin receptor subtype melatonin receptor 1a (MT1) gene expression, and the negative effects of melatonin on milk fat synthesis were reversed by treatment with the nonselective MT1/melatonin receptor subtype melatonin receptor 1b (MT2) antagonist. However, a selective MT2 antagonist did not modify the negative effects of melatonin on milk fat synthesis. In addition, KEGG analysis revealed that melatonin inhibition of milk fat synthesis may occur via the mTOR signaling pathway. Further analysis revealed that melatonin significantly suppressed the activation of the mTOR pathway by restricting the phosphorylation of mTOR, 4E‐BP1, and p70S6K, and the inhibition of melatonin on milk fat synthesis was reversed by mTOR activator MHY1485 in BMECs. Furthermore, in vivo experiments in Holstein dairy cows showed that exogenous melatonin significantly decreased milk fat concentration. Our data from in vitro and in vivo studies revealed that melatonin suppresses milk fat synthesis by inhibiting the mTOR signaling pathway via the MT1 receptor in BMECs. These findings lay a foundation to identify a new potential means for melatonin to modulate the fat content of raw milk in Holstein dairy cows.