The cannabinoid receptor CB2 is predominately expressed in the immune system, and selective modulation of CB2 without the psychoactivity of CB1 has therapeutic potential in inflammatory, fibrotic, and neurodegenerative diseases. Here, we report the crystal structure of human CB2 in complex with a rationally designed antagonist, AM10257, at 2.8 Å resolution. The CB2-AM10257 structure reveals a distinctly different binding pose compared with CB1. However, the extracellular portion of the antagonist-bound CB2 shares a high degree of conformational similarity with the agonist-bound CB1, which led to the discovery of AM10257’s unexpected opposing functional profile of CB2 antagonism versus CB1 agonism. Further structural analysis using mutagenesis studies and molecular docking revealed the molecular basis of their function and selectivity for CB2 and CB1. Additional analyses of our designed antagonist and agonist pairs provide important insight into the activation mechanism of CB2. The present findings should facilitate rational drug design toward precise modulation of the endocannabinoid system.