Postoperative pain affects most patients after major surgery and can transition to chronic pain. The considerable side effects and limited efficacy of current treatments underline the need for new therapeutic options. We observed increased amounts of the metabolites BH4 and serotonin after skin injury. Mast cells were primary postoperative sources of Gch1, the rate-limiting enzyme in BH4 synthesis, itself an obligate cofactor in serotonin production by tryptophan hydroxylase (Tph1). Mice deficient in mast cells or in mast cell-specific Gch1 or Tph1 showed drastically decreased postoperative pain. We found that injury induced the nociceptive neuropeptide substance P, mast cell degranulation, and granule nerve colocalization. Substance P triggered serotonin release in mouse and human mast cells, and substance P receptor blockade substantially ameliorated pain hypersensitivity. Our findings highlight the importance of mast cells at the neuroimmune interface and substance P-driven mast cell BH4 and serotonin production as a therapeutic target for postoperative pain treatment.