The μ-opioid receptor (μOR) is a G-protein-coupled receptor (GPCR) and the target of most clinically and recreationally used opioids. The induced positive effects of analgesia and euphoria are mediated by μOR signalling through the adenylyl cyclase-inhibiting heterotrimeric G protein Gi. Here we present the 3.5 Å resolution cryo-electron microscopy structure of the μOR bound to the agonist peptide DAMGO and nucleotide-free Gi. DAMGO occupies the morphinan ligand pocket, with its N terminus interacting with conserved receptor residues and its C terminus engaging regions important for opioid-ligand selectivity. Comparison of the μOR-Gi complex to previously determined structures of other GPCRs bound to the stimulatory G protein Gs reveals differences in the position of transmembrane receptor helix 6 and in the interactions between the G protein α-subunit and the receptor core. Together, these results shed light on the structural features that contribute to the Gi protein-coupling specificity of the µOR.