To assess postoperative endophthalmitis (POE) rates and risk factors after secondary intraocular lens (IOL) implantation for preoperative aphakia and IOL exchange combined with or without vitrectomy. Medicare fee for service (FFS) beneficiaries, United States. Retrospective study. Medicare FFS beneficiaries who underwent IOL exchange or secondary IOL implantation for preoperative aphakia between January 1, 2011 - November 19, 2022 were identified. POE rates were calculated overall and separately for each surgical category - secondary IOL for aphakia versus IOL exchange, with subsets for concurrent anterior or posterior vitrectomy. Multi-variate analysis of potential risk factors was implemented. 97,152 patients were included. The 42-day POE rates for secondary IOL implantation for aphakia and for IOL exchange were 0.35% and 0.28% overall, 0.31% and 0.30% when combined with posterior vitrectomy, and 0.84% and 0.42% with anterior vitrectomy. The risk of POE increased when secondary IOL surgery was combined with anterior vitrectomy compared to no vitrectomy (adjusted odds ratio [aOR] 1.849; p<0.001) and with higher Charlson comorbidity indexes compared to 0: 1-2 (aOR 1.495; p=0.01), 3-4 (aOR 1.591; p=0.01), 5-6 (aOR 1.617; p=0.046), ≥7 (aOR 3.290; p<0.001). Risk was decreased for IOL exchange compared to secondary IOL implantation for preoperative aphakia (aOR 0.783; p=0.04). The overall POE rate for all secondary IOL surgeries was 0.31% during the 11-year period. We hypothesize that absence of the posterior capsular barrier would explain the higher POE rates compared with cataract surgery, especially if a concurrent vitrectomy was performed with the secondary IOL procedure.