IMPORTANCE Immune dysfunction underlies the pathogenesis of rheumatoid arthritis (RA) and inflammatory bowel disease (IBD). Immunosuppressive therapy is the standard of care for these diseases. Both immune dysfunction and therapy-related immunosuppression can inhibit cancer-related immune surveillance in this population. Drug-induced immunosuppression is a risk factor for nonmelanoma skin cancer (NMSC), particularly squamous cell tumors. For patients with a history of NMSC, data are limited on the effect of these drugs on the risk of additional NMSCs. OBJECTIVE To determine the relative hazard of a second NMSC in patients with RA or IBD who use methotrexate, anti-tumor necrosis factor (anti-TNF) therapy, or thiopurines after an initial NMSC. DESIGN, SETTING, AND PARTICIPANTS In this retrospective cohort study,we studied 9460 individuals with RA or IBD enrolled in Medicare from January 1, 2006, through December 31, 2012. EXPOSURES Exposure to methotrexate, thiopurines, anti-TNFs, sulfasalazine, hydroxychloroquine, abatacept, or rituximab after the incident NMSC surgery. MAIN OUTCOMES AND MEASURES A second NMSC occurring 1 year or more after the incident NMSC using Cox proportional hazards regression models. RESULTS Among 9460 individuals (6841 with RA and 2788 with IBD), the incidence rate of a second NMSC per 1000 person-years was 58.2 (95%CI, 54.5-62.1) and 58.9 (95%CI, 53.2-65.2) in patients with RA and IBD, respectively. Among patients with RA,methotrexate used in conjunction with other medications was associated with an increased risk of a second NMSC (hazard ratio [HR], 1.60; 95%CI, 1.08-2.37). Adjusted for other medications, the risk of NMSC increased with 1 year or more of methotrexate use (HR, 1.24; 95%CI, 1.04-1.48). Compared with methotrexate alone, the addition of anti-TNF drugs was significantly associated with risk of NMSC (HR, 1.49; 95%CI, 1.03-2.16). Abatacept and rituximab were not associated with increased NMSC risk. The nonsignificant HRs for 1 year or more of thiopurine and anti-TNF use for IBD were 1.49 (95%CI, 0.98-2.27) and 1.36 (95%CI, 0.76-2.44), respectively. CONCLUSIONS AND RELEVANCE Methotrexate use is associated with an increased risk of a second NMSC. Anti-TNF use may increase the risk of a second NMSC when used with methotrexate for RA. Further long-Term studies are required before one can conclude that thiopurine and/or anti-TNF do not increase the risk of a second NMSC in patients with IBD.