The gut immune, cannabinoid, and opioid systems constitute an integrated network contributing to visceral sensation and pain modulation. We aimed to assess the expression of the µ-opioid receptor (MOR), its ligand β-endorphin (β-END), and cannabinoid receptor-2 (CB2 ) in patients with irritable bowel syndrome (IBS) and asymptomatic controls (AC) and their correlation with sex and symptom perception. Mucosal biopsies were obtained from the left colon of 31 IBS patients (45% women) with predominant constipation (IBS-C, 9) or diarrhea (IBS-D, 10) or with mixed bowel habits (IBS-M, 12) and 32 AC (44% women) and processed for qRT-PCR, Western blotting, and immunohistochemistry. µ-opioid receptor and CB2 mRNA and protein expression and β-END protein levels were increased in patients with IBS compared to AC (all Ps=0.021). A significant sex by IBS interaction was found in relation to CB2 mRNA expression (P = .003) with women showing a markedly higher expression to men (P = .035). In contrast, in AC, men had higher expression than women (P = .033). β-END, MOR, and CB2 immunoreactivities (IR) were localized to CD4+T cells including EMR-1+ eosinophils and CD31+ T cells but not to mast cells. The increased expression of MOR, β-END, and CB2 in the mucosa of IBS patients, where they are localized to immune cells, suggests that opioid and cannabinoid systems play an immune-related compensatory role in visceral pain in IBS patients. Further work is necessary to support this hypothesis. © 2019 John Wiley & Sons Ltd.