The prevalence of chronic pain in patients with chronic kidney disease (CKD) and diabetes mellitus is high and correlates with higher frailty risk, but satisfactory pain control frequently fails, necessitating opioid initiation. We aimed to examine whether opioid use affected their outcomes and whether such a relationship was modified by frailty. From the longitudinal cohort of diabetes patients (n = 840,000), we identified opioid users with CKD (n = 26,029) and propensity score-matched them to opioid-naïve patients in a 1:1 ratio. We analyzed the associations between opioid use and long-term mortality according to baseline frailty status, defined by the modified FRAIL scale. Among all, 20.3% did not have any FRAIL items, while 57.2%, 20.6%, and 1.9% had 1, 2, and at least 3 positive FRAIL items, respectively. After 4.2 years, 16.4% died. Cox proportional hazard regression showed that opioid users exhibited an 18% higher mortality risk (HR 1.183, 95% CI 1.13-1.24) with a dose- and duration-responsive relationship, compared to opioid-naive ones. Furthermore, the mortality risk posed by opioids was observed only in CKD patients without frailty but not in those with frailty. In conclusion, opioid use increased mortality among patients with CKD, while this negative outcome influence was not observed among frail ones.