Sleep can affect nonalcoholic fatty liver disease (NAFLD). We investigated the association between sleep duration, sleep quality, and NAFLD. From January to December 2018, 1,073 patients (age: 37.94 ± 10.88, Body Mass Index (BMI): 22.85 ± 3.27) were enrolled. Pittsburgh Sleep Quality Index Questionnaire and Munich Chronotype Questionnaire were used to assess sleep duration, quality, and habits. Ultrasonography was used to diagnose NAFLD. Multivariate logistic regression models were used to calculate the odds ratio (OR) and 95% confidence interval (CI) of the risk of NAFLD by different types of sleep duration and sleep quality. No significant differences in sleep time, sleep quality, and sleep habits between the NAFLD and the non-NAFLD groups were observed (P > 0.05). There was no correlation between sleep duration and NAFLD in the whole cohort. After adjusting for age, exercise, fasting plasma glucose, and BMI, the group with long sleep duration showed a decreased risk of NAFLD in men (OR = 0.01, 95% CI: 0.001–0.27, P = 0.032). However, in all four adjusted models, no correlation between sleep duration, quality, and NAFLD was found in women. In conclusion, sleep duration was significantly and negatively associated with NAFLD in men but not women. Prospective studies are required to confirm this association.