BACKGROUND: Climate change is expected to have significant effects on human health, partly through an increase in extreme events such as heatwaves. People with mental illness may be at particular risk. AIMS: To estimate risk conferred by high ambient temperature on patients with psychosis, dementia and substance misuse. METHOD: We applied time-series regression analysis to data from a nationally representative primary care cohort study. Relative risk of death per 1°C increase in temperature was calculated above a threshold. RESULTS: Patients with mental illness showed an overall increase in risk of death of 4.9% (95% CI 2.0-7.8) per 1°C increase in temperature above the 93rd percentile of the annual temperature distribution. Younger patients and those with a primary diagnosis of substance misuse demonstrated greatest mortality risk. CONCLUSIONS: The increased risk of death during hot weather in patients with psychosis, dementia and substance misuse has implications for public health strategies during heatwaves.