Increasing age leads to physical, psychological, and social changes that affect the quality of life of the elderly, especially those suffering from chronic diseases such as Diabetes Mellitus (DM). The elderly are prone to cognitive function impairment, including decline in memory, concentration, and problem-solving abilities. Data from BPS (2023) show an increase in the elderly population, with the Special Region of Yogyakarta being the province with the highest proportion. A preliminary study at Sleman Primary Health Center indicated that 40% of the elderly experience mild to severe cognitive function impairment. To determine the relationship between cognitive function and quality of life among elderly patients in the Prolanis program at Sleman Primary Health Center, Yogyakarta. This study employed a quantitative research design using a cross-sectional approach. The total population was 476 respondents, with a sample of 83 respondents selected through purposive sampling. The study was conducted at Sleman Primary Health Center, Yogyakarta. The research instruments used were the MMSE questionnaire and the WHOQOL-BREF questionnaire. Bivariate analysis was performed using Kendall's Tau test. The majority of the elderly were aged 60–74 years (69.9%), female (75.9%), unemployed (49.4%), and had had DM for more than 5 years (44.6%). A total of 48.2% had moderate cognitive function, and 62.7% had moderate quality of life. The Kendall's Tau test showed a positive and significant relationship between cognitive function and quality of life (r = 0.301; p = 0.002). There is a positive and significant relationship between cognitive function and quality of life among the elderly. The better the cognitive ability of the elderly, the higher their perceived quality of life.