Background: Hypogonadism is prevalent during opioid treatment, but the effect of testosterone replacement treatment (TRT) on body composition, pain perception, and adrenal function is unclear. Purpose: To measure changes in body composition, pain perception, quality of life, and adrenal function after TRT or placebo in opioid-treated men with chronic non-malignant pain. Methods: Double-blind, placebo-controlled study in 41 men (>18 years) with total testosterone <12 nmol/L were randomized to 24 weeks TRT (Testosterone undecanoate injection three times/6 months, n = 20) or placebo (placebo-injections, n = 21). Outcomes: Body composition (lean body mass and fat mass assessed by DXA), clinical pain intensity (numerical rating scale), and experimental pain perception (quantitative sensory assessment), quality of life (SF36), and adrenocorticotrophic hormone (ACTH) test. Data were presented as median (quartiles). Mann-Whitney tests were performed on delta values (24-0 weeks) between TRT and placebo. Results: The median age was 55 years (46; 59) and total testosterone before intervention was 6.8 (5.0; 9.3) nmol/L. TRT was associated with change of testosterone levels: 12.3 (7.0; 19.9) nmol/L (P < 0.001 vs placebo), increased lean body mass: 3.6 (2.3; 5.0) kg vs 0.1 kg (-2.1; 1.5) during TRT vs placebo and decreased total fat mass: -1.2 (-3.1; 0.7) kg vs 1.2 kg (-0.9; 2.5) kg, both P < 0.003. Changed pain perception, SF36, and ACTH-stimulated cortisol levels were non-significantly changed during TRT compared with placebo. Conclusions: Six months of TRT improved body composition in men with opioid-induced hypogonadism without significant changes in outcomes of pain perception, quality of life, or adrenal function.