Background: Depression and pain often coexist in terminally ill patients, but few studies have examined their relationship among larger samples. Other psychosocial factors experienced by patients may become barriers to pain management and affect the relationship between depression and pain. Objective: This study aims to examine the relationship between depression and pain in terminally ill Chinese elders in Hong Kong and explore the moderating effect of psychosocial factors such as loneliness, communication, and being at ease interacting with others. Methods: A secondary data analysis was conducted on a large cohort of community-dwelling Chinese elders applying for long-term care service in Hong Kong between 2004 and 2009. A total of 312 elders who had a prognosis of less than 6 months were included. Results: Depression was associated positively and significantly with pain. However, loneliness moderated this relationship, and for participants who felt lonely, depression and pain were no longer significantly associated. Conclusions: Findings support the positive relationship between depression and pain in terminally ill elders. Feeling lonely may affect the tendency to report pain. To ensure optimal pain management for patients in palliative and end-of-life care, assessment and intervention should focus on the impact of psychosocial factors such as loneliness, and how they may affect elders' reporting of pain.