Hypnotics are frequently used in depressed patients, but factors determining long-term use remain uncertain. Using national health registers, we included patients aged ≥18 years in Sweden 2007-2018 who filled a prescription for any drug indicated for sleep within three months after a diagnosis of depression in psychiatric specialist care. We excluded patients with dementia, bipolar or psychotic disorders, and those who had been Swedish residents for <12 months. Patients were followed for one year. Long-term use was defined as >180 defined daily doses of hypnotics across ≥3 prescription fills, including ≥1 fill in the second half of the year. Logistic regression was used to calculate unadjusted and adjusted odds ratios (ORs, aORs) with 95% confidence intervals (CI) to identify factors associated with long-term hypnotic use. We included 78,383 patients (mean age 39.4 years, 58.4% women). The most commonly initiated drug was a benzodiazepine-like hypnotic (Z-drug; n = 40,008; 51.0%), followed by the phenothiazine propiomazine (n = 30,940; 39.5%), melatonin (n = 6415; 8.2%), and benzodiazepine hypnotics (n = 1020; 1.3%). Overall, 23,476 of 78,383 patients (30.0%) met the criteria for long-term hypnotic use. In the adjusted model, older age was strongly associated with long-term hypnotic use (≥70 vs. 18-29 years: aOR 2.27, 95%CI 2.08-2.47), as was higher number of antidepressants in the past year (≥3 vs. 0: aOR 3.23, 95%CI 2.97-3.53). In this large cohort of patients with unipolar depression initiating hypnotic treatment, long-term use was more likely in older patients and those with multiple prior antidepressant trials, highlighting the need for careful clinical attention in these groups.