Persistent pain after total knee replacement is an underestimated outcome leading to significant health burden. Sensory testing has been explored to help surgeons in decision making and better patient selection. Patients with different chronic pain syndromes exhibit a poor descending pain inhibition that can be quantified through experimental paradigms (conditioned pain modulation). A poor preoperative descending pain inhibition response predicted persistence of pain after surgery in previous studies. This study investigated the correlation between a preoperative inefficient endogenous analgesia and a bad postoperative pain outcome (painful prosthesis). One hundred forty-six patients were studied preoperatively by quantitative sensory testing. Conditioned pain modulation was calculated as the relative decrease in pain intensity (thermal stimulus) during heterotopic painful stimulation. Approximately 21.2% of patients had a bad pain outcome (painful prosthesis), 6 months after surgery. Preoperatively, 47.9% of patients exhibited an insufficient endogenous analgesia. The probability to develop persistent pain after surgery in that group was higher than that in patients with a sufficient endogenous analgesia (31.4% [20.9-43.6, 95% CI] vs 11.8% [5.5-21.3, 95% CI], respectively; P < 0.004). Correlation between conditioned pain modulation values and postoperative intensity of pain was also established. Besides, a preoperative lower quality of life (mental component) predicted a worse pain outcome, too. This cohort study shows that preoperative sensory testing predicts a bad pain outcome after total knee replacement. This tool could help clinicians in a better indication of patients with advanced knee osteoarthritis for replacement surgery. ClinicalTrials.gov: NCT01811888 (prospective).