Cognitive impairment is common and linked to poor outcomes in patients with late-onset depression (LOD). The cognitive effects of repetitive transcranial magnetic stimulation (rTMS) for LOD are not well understood. This study aimed to investigate the effects of rTMS on cognitive function in elderly patients with LOD. In total, 58 elderly patients (aged 60 to 75 years) with depression were enrolled and randomly assigned to an active rTMS group or a sham group. The participants received active or sham rTMS over the left dorsolateral prefrontal cortex for 4 weeks, 5 days a week, at a frequency of 10 Hz rTMS and 120% of the motor threshold (MT). Cognitive function was assessed using the Repeatable Battery for the Assessment of Neuropsychological Status (RBANS) at baseline, the end of the 4 week treatment period, and at the 4 week follow-up. The active rTMS group showed significant improvements in immediate memory and attention scores on the RBANS compared to the sham group. However, no significant differences were observed between the two groups in other cognitive domains assessed by the RBANS. No serious adverse events related to rTMS treatment were observed. Treatment with 120% MT rTMS was associated with improvement in cognitive defects related to the active phase of LOD. These findings suggest that rTMS could provide early improvements in cognitive function in clinical settings for elderly patients with LOD.Clinical trial registration: https://www.chictr.org.cn/showproj.html?proj=40698, identifier ChiCTR1900024445.