In this study, we examined the existence of relationship between sleep quality and dementia in subjects aged 90 years and above. The sample included 216 men and 444 women. Dementia and sleep quality were measured with 30-item mini-mental state examination (MMSE) and the Pittsburgh sleep quality index, respectively. Subjects with dementia had higher sleep quality score (7.83 ± 2.15 vs. 5.22 ± 2.49; P < 0.0001), longer sleep latency (50.97 ± 21.33 vs. 37.61 ± 12.53; P < 0.0001), and a lower sleep efficiency percentage (73.95 ± 8.783 vs. 81.32 ± 10.21; P < 0.0001) and more likely to report poor sleep quality (25.42 vs.17.13 %; P 0 0.035). Subjects with poor sleep quality had significantly lower MMSE scores (P 0 0.007) and higher prevalence of dementia (P 0 0.042). Multiple logistic regressions were performed by adjusting clinical factors that are thought to be associated with dementia or sleep quality. We found that poor sleep quality was a risk factor for dementia (unadjusted odds ratio (OR) 1.719, 95 % confidence interval (CI) 1.138-2.597; adjusted OR 1.759, 95 % CI 1.012-3.057). There was no significant difference in MMSE scores (11.25 ± 3.40, 16.26 ± 5.14, and 15.43 ± 5.51; P 0 0.105) among participants with daily average sleep durations of <5, 5-9, and >9 h, respectively. Among Chinese nonagenarians and centenarians, dementia was correlated with poor sleep quality, longer sleep latency, and lower sleep efficiency percentage.