Behavioural, cognitive, and pharmacological interventions can all be effective for insomnia. However, because of inadequate resources, medications are more frequently used worldwide. We aimed to estimate the comparative effectiveness of pharmacological treatments for the acute and long-term treatment of adults with insomnia disorder. In this systematic review and network meta-analysis, we searched the Cochrane Central Register of Controlled Trials, MEDLINE, PubMed, Embase, PsycINFO, WHO International Clinical Trials Registry Platform, ClinicalTrials.gov, and websites of regulatory agencies from database inception to Nov 25, 2021, to identify published and unpublished randomised controlled trials. We included studies comparing pharmacological treatments or placebo as monotherapy for the treatment of adults (≥18 year) with insomnia disorder. We assessed the certainty of evidence using the confidence in network meta-analysis (CINeMA) framework. Primary outcomes were efficacy (ie, quality of sleep measured by any self-rated scale), treatment discontinuation for any reason and due to side-effects specifically, and safety (ie, number of patients with at least one adverse event) both for acute and long-term treatment. We estimated summary standardised mean differences (SMDs) and odds ratios (ORs) using pairwise and network meta-analysis with random effects. This study is registered with Open Science Framework, https://doi.org/10.17605/OSF.IO/PU4QJ. We included 170 trials (36 interventions and 47 950 participants) in the systematic review and 154 double-blind, randomised controlled trials (30 interventions and 44 089 participants) were eligible for the network meta-analysis. In terms of acute treatment, benzodiazepines, doxylamine, eszopiclone, lemborexant, seltorexant, zolpidem, and zopiclone were more efficacious than placebo (SMD range: 0·36-0·83 [CINeMA estimates of certainty: high to moderate]). Benzodiazepines, eszopiclone, zolpidem, and zopiclone were more efficacious than melatonin, ramelteon, and zaleplon (SMD 0·27-0·71 [moderate to very low]). Intermediate-acting benzodiazepines, long-acting benzodiazepines, and eszopiclone had fewer discontinuations due to any cause than ramelteon (OR 0·72 [95% CI 0·52-0·99; moderate], 0·70 [0·51-0·95; moderate] and 0·71 [0·52-0·98; moderate], respectively). Zopiclone and zolpidem caused more dropouts due to adverse events than did placebo (zopiclone: OR 2·00 [95% CI 1·28-3·13; very low]; zolpidem: 1·79 [1·25-2·50; moderate]); and zopiclone caused more dropouts than did eszopiclone (OR 1·82 [95% CI 1·01-3·33; low]), daridorexant (3·45 [1·41-8·33; low), and suvorexant (3·13 [1·47-6·67; low]). For the number of individuals with side-effects at study endpoint, benzodiazepines, eszopiclone, zolpidem, and zopiclone were worse than placebo, doxepin, seltorexant, and zaleplon (OR range 1·27-2·78 [high to very low]). For long-term treatment, eszopiclone and lemborexant were more effective than placebo (eszopiclone: SMD 0·63 [95% CI 0·36-0·90; very low]; lemborexant: 0·41 [0·04-0·78; very low]) and eszopiclone was more effective than ramelteon (0.63 [0·16-1·10; very low]) and zolpidem (0·60 [0·00-1·20; very low]). Compared with ramelteon, eszopiclone and zolpidem had a lower rate of all-cause discontinuations (eszopiclone: OR 0·43 [95% CI 0·20-0·93; very low]; zolpidem: 0·43 [0·19-0·95; very low]); however, zolpidem was associated with a higher number of dropouts due to side-effects than placebo (OR 2·00 [95% CI 1·11-3·70; very low]). Overall, eszopiclone and lemborexant had a favorable profile, but eszopiclone might cause substantial adverse events and safety data on lemborexant were inconclusive. Doxepin, seltorexant, and zaleplon were well tolerated, but data on efficacy and other important outcomes were scarce and do not allow firm conclusions. Many licensed drugs (including benzodiazepines, daridorexant, suvorexant, and trazodone) can be effective in the acute treatment of insomnia but are associated with poor tolerability, or information about long-term effects is not available. Melatonin, ramelteon, and non-licensed drugs did not show overall material benefits. These results should serve evidence-based clinical practice. UK National Institute for Health Research Oxford Health Biomedical Research Centre.