BackgroundMigraine is a highly disabling health burden with multiple symptoms; however, it remains undertreated because of an inadequate understanding of its neural mechanisms. Neuropeptide Y (NPY) has been demonstrated to be involved in the modulation of pain and emotion, and may play a role in migraine pathophysiology. Changes in NPY levels have been found in patients with migraine, but whether and how these changes contribute to migraine is unknown. Therefore, the purpose of this study was to investigate the role of NPY in migraine-like phenotypes.MethodsHere, we used intraperitoneal injection of glyceryl trinitrate (GTN, 10 mg/kg) as a migraine mouse model, which was verified by light-aversive test, von Frey test, and elevated plus maze test. We then performed whole-brain imaging with NPY-GFP mice to explore the critical regions where NPY was changed by GTN treatment. Next, we microinjected NPY into the medial habenula (MHb), and further infused Y1 or Y2 receptor agonists into the MHb, respectively, to detect the effects of NPY in GTN-induced migraine-like behaviors.ResultsGTN effectively triggered allodynia, photophobia, and anxiety-like behaviors in mice. After that, we found a decreased level of GFP+cells in the MHb of GTN-treated mice. Microinjection of NPY attenuated GTN-induced allodynia and anxiety without affecting photophobia. Furthermore, we found that activation of Y1—but not Y2—receptors attenuated GTN-induced allodynia and anxiety.ConclusionsTaken together, our data support that the NPY signaling in the MHb produces analgesic and anxiolytic effects through the Y1 receptor. These findings may provide new insights into novel therapeutic targets for the treatment of migraine.Graphical AbstractSupplementary InformationThe online version contains supplementary material available at 10.1186/s10194-023-01596-z.