Background: Early weight gain during inpatient treatment for anorexia nervosa (AN) is an important predictor of overall treatment outcome. However, weight gain is a dynamic process characterized by within-person variability that may also be age-dependent. Therefore, we examined whether age moderates the effect of within-person weight gain and variability on treatment outcome.Methods: Within-person level estimates of N = 2881 underweight adolescents and adults with AN for daily average weight gain (linear slope) and variability (root mean squared errors) were obtained using random-effects modelling. Linear and logistic regression analyses at the between-person level were calculated to assess their effects on weight, core eating disorder psychopathology and weight restoration. Results: Higher weight gain during the first two weeks of inpatient treatment predicted higher discharge weight, lower drive for thinness and lower body dissatisfaction at discharge, but was not associated with changes in bulimic symptoms. Moreover, higher early weight gain predicted a higher probability of weight restoration at discharge. Moderation analyses revealed that younger age was significantly associated with a stronger effect of early weight gain on weight, drive for thinness and body dissatisfaction at discharge, but was not associated with a higher likelihood of weight restoration. Weight variability was not associated with any treatment outcome. Conclusion: Age moderated the effect of early weight gain on treatment outcome, with larger effects for younger patients. Weight variability did not substantially influence treatment outcome across age and should be of lesser clinical concern during early inpatient treatment when patients gain weight on average.