Cortical myelin loss and repair in multiple sclerosis (MS) have been explored in neuropathological studies, but the impact of these processes on neurodegeneration and the irreversible clinical progression of the disease remains unknown. Here, we evaluated in vivo cortical demyelination and remyelination in a large cohort of people with all clinical phenotypes of MS followed up for 5 years using magnetization transfer imaging (MTI), a technique that has been shown to be sensitive to myelin content changes in the cortex. We investigated 140 people with MS (37 clinically isolated syndrome, 71 relapsing-MS, 32 progressive-MS), who were clinically assessed at baseline and after 5 years and, along with 84 healthy controls, underwent a 3 T-MRI protocol including MTI at baseline and after 1 year. Changes in cortical volume over the radiological follow-up were computed with a Jacobian integration method. Magnetization transfer ratio was employed to calculate for each patient an index of cortical demyelination at baseline and of dynamic cortical demyelination and remyelination over the follow-up period. The three indices of cortical myelin content change were heterogeneous across patients but did not significantly differ across clinical phenotypes or treatment groups. Cortical remyelination, which tended to fail in the regions closer to CSF (-11%, P < 0.001), was extensive in half of the cohort and occurred independently of age, disease duration and clinical phenotype. Higher indices of cortical dynamic demyelination (β = 0.23, P = 0.024) and lower indices of cortical remyelination (β = -0.18, P = 0.03) were significantly associated with greater cortical atrophy after 1 year, independently of age and MS phenotype. While the extent of cortical demyelination predicted a higher probability of clinical progression after 5 years in the entire cohort [odds ratio (OR) = 1.2; P = 0.043], the impact of cortical remyelination in reducing the risk of accumulating clinical disability after 5 years was significant only in the subgroup of patients with shorter disease duration and limited extent of demyelination in cortical regions (OR = 0.86, P = 0.015, area under the curve = 0.93). In this subgroup, a 30% increase in cortical remyelination nearly halved the risk of clinical progression at 5 years, independently of clinical relapses. Overall, our results highlight the critical role of cortical myelin dynamics in the cascade of events leading to neurodegeneration and to the subsequent accumulation of irreversible disability in MS. Our findings suggest that early-stage myelin repair compensating for cortical myelin loss has the potential to prevent neuro-axonal loss and its long-term irreversible clinical consequences in people with MS.