BackgroundLow magnesium and vitamin D levels negatively affect individuals’ health.AimsWe aimed to investigate the association of magnesium status with grip strength and fatigue scores, and evaluate whether this association differs by vitamin D status among older participants undergoing geriatric rehabilitation.MethodsThis is a 4-week observational study of participants aged ≥ 65 years undergoing rehabilitation. The outcomes were baseline grip strength and fatigue scores, and 4-week change from baseline in grip strength and fatigue scores. The exposures were baseline magnesium tertiles and achieved magnesium tertiles at week 4. Pre-defined subgroup analyses by vitamin D status (25[OH]D < 50 nmol/l = deficient) were performed.ResultsAt baseline, participants (N = 253, mean age 75.7 years, 49.4% women) in the first magnesium tertile had lower mean grip strength compared to participants in the third tertile (25.99 [95% CI 24.28–27.70] vs. 30.1 [95% CI 28.26–31.69] kg). Similar results were observed among vitamin D sufficient participants (25.54 [95% CI 22.65–28.43] kg in the first magnesium tertile vs. 30.91 [27.97–33.86] kg in the third tertile). This association was not significant among vitamin D deficient participants. At week 4, no significant associations were observed between achieved magnesium tertiles and change in grip strength, overall and by vitamin D status. For fatigue, no significant associations were observed.ConclusionsAmong older participants undergoing rehabilitation, magnesium status may be relevant for grip strength, particularly among vitamin D sufficient individuals. Magnesium status was not associated with fatigue, regardless of vitamin D status.Study registrationClinicaltrials.gov, NCT03422263; registered February 5, 2018.Supplementary InformationThe online version contains supplementary material available at 10.1007/s40520-023-02450-7.