Serious mental illness (SMI) may compromise diabetes self-management. This study assessed the association between SMI and glycemic control, and explored sociodemographic predictors and geographic clustering of this outcome among patients with and without SMI. We used electronic health record data for adult primary care patients with diabetes from 2 San Francisco health care delivery systems. The primary outcome was poor glycemic control (hemoglobin A1c >9.0%), which was modeled on SMI diagnosis status and sociodemographics. Geospatial analyses examined hotspots of poor glycemic control and neighborhood characteristics. The study included 11 694 participants with diabetes, 21% with comorbid SMI, of whom 22% had a schizophrenia spectrum or bipolar disorder. Median age was 62 years; 52% were female and 79% were Asian, Black, or Hispanic. In adjusted models, having schizophrenia spectrum disorder or bipolar disorder was associated with greater risk for poor glycemic control (vs participants without SMI, adjusted relative risk [aRR] = 1.24; 95% confidence interval, 1.02, 1.49), but having broadly defined SMI was not. People with and without SMI had similar sociodemographic correlates of poor glycemic control including younger versus older age, Hispanic versus non-Hispanic White race/ethnicity, and English versus Chinese language preference. Hotspots for poor glycemic control were found in neighborhoods with more lower-income, Hispanic, and Black residents. Poor diabetes control was significantly related to having a schizophrenia spectrum or bipolar disorder, and to sociodemographic factors and neighborhood. Community-based mental health clinics in hotspots could be targets for implementation of diabetes management services.