ObjectiveTo improve mechanistic understanding, this randomized controlled trial examined anxiety, mood, emotional support, and pain‐related self‐efficacy as mediators of music therapy for pain management in people with advanced cancer.MethodsPeople with advanced cancer who had chronic pain were randomized (1:1) to 6 weekly individual music therapy or social attention control sessions. We measured mediators and pain outcomes (pain interference and pain intensity) using self‐report measures at baseline, session 4, and post‐intervention. We included outcome expectancy/treatment credibility, music reward, adult playfulness, and baseline pain interference and pain intensity as moderators.ResultsParticipants (n = 92) had a mean age of 56 years. Most were female (71.7%), white (47.8%) or Black (39.1%), and had stage IV cancer (75%). Self‐efficacy was found to be a significant mediator of music therapy for pain intensity (indirect effect ab = 0.79, 95% CI 0.01–1.82) and pain interference (indirect effect ab = 1.16, 95% CI 0.02–2.51), while anxiety, mood, and emotional support were not. The mediating effect of pain‐related self‐efficacy was significantly moderated by baseline pain interference but not by the other moderators.ConclusionsThe findings suggest that the impact of music therapy on chronic pain is mediated by self‐efficacy. This knowledge can help optimize music therapy interventions for chronic pain management for people with advanced cancer by capitalizing on teaching music‐based self‐management strategies.Trial Registration: ClinicalTrials.gov identifier: NCT03432247