Objective: To assess sleep quality and the association of trait and state anxiety in patients with diabetes mellitus. Method: A cross-sectional, quantitative, and analytical study was conducted between January and April 2022, at the reference center for hypertension and diabetes in Rio Verde, Goiás, with 81 patients. The Pittsburgh Sleep Quality Index and State-Trait Anxiety Inventory were used for data collection. Analyses included the Student’s t-test and multivariate logistic regression analysis. Results: Of patients, 64.2% reported poor sleep quality. There were significant differences in trait anxiety levels between patients with good and poor sleep quality. Trait anxiety was associated with sleep quality, with an increase in the trait anxiety score increasing the chances of poor sleep quality. Conclusion: A significant proportion of the sample had poor sleep quality, and trait anxiety was found to be associated with this condition.