BackgroundChildhood experience has been suggested to affect cognitive function in later life. However, the association between childhood friendship status and cognitive ageing trajectory in middle-aged and older adults has not been fully assessed. This study examined the association between childhood friendship status and cognitive ageing trajectory and identified factors modifying this association.MethodsWe used four waves of data from the China Health and Retirement Longitudinal Study (CHARLS), a national representative longitudinal study of adults aged 45 years or older, 2011–2018. The CHARLS included surveys on childhood friendship and cognitive assessments. Childhood friendship status was categorised as poor, fair, and good. To examine the association between childhood friendship and cognitive ageing trajectory in later life, we applied multilevel linear regression models, and explored potential influences of sociodemographic factors, health status and behaviours, and childhood conditions on this association.ResultsOf the 4,350 participants, 1,919 (44.1%) were women. The mean age was 56.29 ± 7.80 years. We found childhood friendship was significantly associated with cognitive ageing trajectory in later life, with a dose–response relationship. After adjusting for covariates, comparing to participants with poor childhood friendships, those with better childhood friendships had lower rates of cognitive decline (β = 0.12, 95% confidence interval [CI]: 0.03 to 0.22 [interaction term of fair friendship and time]; β = 0.19, 95% CI: 0.10 to 0.28 [interaction term of good friendship and time]) and higher level of cognitive functions (β = 0.40, 95% CI: 0.22 to 0.58 [fair friendships]; β = 0.61, 95% CI: 0.43 to 0.79 [good friendships]). These associations were stronger for those who were female, less educated, and had experienced more adverse childhood experiences.ConclusionsChildhood friendship is associated with cognitive ageing in later life. Enhancing childhood friendships can play an important role to promote healthy ageing in the future.Supplementary InformationThe online version contains supplementary material available at 10.1186/s12877-022-03181-6.