The human MAS-related G protein-coupled receptor X1 (MRGPRX1) is preferentially expressed in the small-diameter primary sensory neurons and involved in the mediation of nociception and pruritus. Central activation of MRGPRX1 by the endogenous opioid peptide fragment BAM8-22 and its positive allosteric modulator ML382 has been shown to effectively inhibit persistent pain, making MRGPRX1 a promising target for non-opioid pain treatment. However, the activation mechanism of MRGPRX1 is still largely unknown. Here we report three high-resolution cryogenic electron microscopy structures of MRGPRX1-Gαq in complex with BAM8-22 alone, with BAM8-22 and ML382 simultaneously as well as with a synthetic agonist compound-16. These structures reveal the agonist binding mode for MRGPRX1 and illuminate the structural requirements for positive allosteric modulation. Collectively, our findings provide a molecular understanding of the activation and allosteric modulation of the MRGPRX1 receptor, which could facilitate the structure-based design of non-opioid pain-relieving drugs.