The cognitive model of insomnia states that worry about sleep contributes to poor sleep quality. Besides worry, beliefs about sleep and maladaptive safety behaviors also affect sleep quality. We aimed to find the association among the presence of insomnia, sleep-related cognitions, and behaviors among patients diagnosed with anxiety or depression. The present cross-sectional comparison study included patients with anxiety spectrum or depressive disorders as per the Diagnostic and Statistical Manual for Mental Disorders-fifth edition and healthy controls. Mood status, insomnia severity, sleep quality, dysfunctional beliefs about sleep, maladaptive safety behaviors, and pre-sleep arousal were evaluated using Hamilton Anxiety Scale (HAM-A), Montgomery Åsberg Depression Rating Scale (MADRS), Insomnia Severity Index, Pittsburgh Sleep Quality Index, Dysfunctional Beliefs and Attitudes Sleep Scale (DBAS), Sleep-related Behavior Questionnaire (SRBQ), and Pre-sleep Arousal Scale (PSAS), respectively. A p value ≤.05 was considered statistically significant. Both patients (n = 80) and controls (n = 80) were similar in sociodemographic profile, though the sample was predominantly female. Comparison between patients with insomnia (n = 60), patients without insomnia (n = 20), and healthy controls (n = 80) showed that HAM-A and MADRS, DBAS, SRBQ, and PSAS scores were higher in patients with insomnia compared to their counterparts. DBAS and SRBQ scores positively correlated with increasing severity of insomnia. Dysfunctional beliefs regarding sleep (OR: 1.05; 95% CI = 1.00-1.09) and maladaptive behaviors related to sleep (OR: 1.02; 95% CI = 1.00-1.05) predicted insomnia in patients with depression or anxiety. Insomnia in anxiety or depression is associated with illness severity, dysfunctional beliefs regarding sleep, and sleep-related maladaptive behaviors. Maladaptive cognitions and behaviors can independently influence sleep quality.