Few controlled studies have specifically investigated aspects of mental health care in relation to suicide risk among recently discharged psychiatric patients. We aimed to identify risk factors, including variation in healthcare received, for suicide within 3 months of discharge. We conducted a national population-based case-control study of 238 psychiatric patients dying by suicide within 3 months of hospital discharge, matched on date of discharge to 238 living controls. Forty-three per cent of suicides occurred within a month of discharge, 47% of whom died before their first follow-up appointment. The first week and the first day after discharge were particular high-risk periods. Risk factors for suicide included a history of self-harm, a primary diagnosis of affective disorder, recent last contact with services and expressing clinical symptoms at last contact with staff. Suicide cases were more likely to have initiated their own discharge and to have missed their last appointment with services. Patients who were detained for compulsory treatment at last admission, or who were subject to enhanced levels of aftercare, were less likely to die by suicide. The weeks after discharge from psychiatric care represent a critical period for suicide risk. Measures that could reduce risk include intensive and early community follow-up. Assessment of risk should include established risk factors as well as current mental state and there should be clear follow-up procedures for those who have self-discharged. Recent detention under the Mental Health Act and current use of enhanced levels of aftercare may be protective.