The endogenous opioid and cannabinoid systems are involved in the physiological inhibitory control of pain and are of particular interest for the development of therapeutic approaches for pain management. The involvement of these endogenous systems in pain control has been studied from decades by the use of compounds with different affinities for each cannabinoid and opioid receptor or for the different enzymes involved in endocannabinoid and endogenous opioid metabolism. However, the selectivity of these pharmacological tools in vivo has represented an important limitation for these studies. The generation of genetically modified mice with selective mutations in specific components of the endocannabinoid and endogenous opioid system has provided important advances in the identification of the specific contribution of each component of these endogenous systems in the perception of noxious stimuli and the development of pathological pain states. Different lines of constitutive and conditional knockout mice deficient in specific cannabinoid and opioid receptors, specific precursors of the endogenous opioid peptides and the main enzymes involved in endocannabinoid and endogenous opioid degradation are now available. These knockout mice have also been used to evaluate the contribution of each component of the endocannabinoid and opioid system in the antinociceptive effects of cannabinoid and opioid agonists, including those currently used to treat pain in humans. This review summarizes the main advances provided in the last 15 years by the use of these genetic tools in the knowledge of the physiological control of pain and the pharmacology of cannabinoid and opioid compounds for pain management.