Elevated keratinocyte carcinoma (KC) risk is present with several immune-related conditions, e.g., solid organ transplantation and non-Hodgkin lymphoma. Because many immune-related conditions are rare, their relationships with KC have not been studied. We used Medicare claims to identify cutaneous squamous cell carcinoma (SCC) and basal cell carcinoma (BCC) cases in 2012, and controls matched on sex and age. All subjects were aged 65–95 years, of white race, and had attended ≥1 dermatologist visit in 2010–2011. Immune-related conditions were identified during 1999–2011 using Medicare claims. Associations were estimated with logistic regression, with statistical significance determined after Bonferroni correction for multiple comparisons. We included 258,683 SCC and 304,903 BCC cases. Of 47 immune-related conditions, 21 and 9 were associated with increased SCC and BCC risk, respectively. We identified strongly elevated KC risk with solid organ transplantation (SCC odds ratio [OR]=5.35; BCC OR=1.94) and non-Hodgkin lymphoma (SCC OR=1.62; BCC OR=1.25). We identified associations with common conditions, e.g., rheumatoid arthritis (SCC OR=1.06, 95% confidence interval [95%CI]=1.04–1.09) and Crohn’s disease (SCC OR=1.33, 95%CI=1.27–1.39; BCC OR=1.10, 95%CI=1.05–1.15), and rare or poorly characterized conditions, e.g., granulomatosis with polyangiitis (SCC OR=1.88, 95%CI=1.61–2.19), autoimmune hepatitis (SCC OR=1.81, 95%CI=1.52–2.16), and deficiency of humoral immunity (SCC OR=1.51, 95%CI=1.41–1.61; BCC OR=1.22, 95%CI=1.14–1.31). Most conditions were more positively associated with SCC than BCC. Associations were generally consistent regardless of prior KC history. Many immune-related conditions are associated with elevated KC risk, and appear more tightly linked to SCC. Immunosuppression or immunosuppressive treatment may increase KC risk, particularly SCC.