Multiple sclerosis is a disease with a highly variable incidence worldwide. While knowledge about multiple sclerosis risk factors has grown over the years, the aetiology of multiple sclerosis has still not been fully established. We examined multiple sclerosis incidence rates among first-generation immigrants in Denmark, a high-incidence country, and their Danish-born children (second-generation immigrants), to evaluate the importance and timing of exposure to environmental factors in the aetiology of multiple sclerosis. By means of the Danish Civil Registration System we identified 9 121 187 individuals living in Denmark between 1968 and 2015, including 1 176 419 first-generation and 184 282 second-generation immigrants. Study participants were followed for multiple sclerosis in the Danish Multiple Sclerosis Registry from 1968 to 2015. The relative risk (RR) of multiple sclerosis according to immigration status was estimated by means of multiple sclerosis incidence rate ratios obtained in log-linear Poisson regression analysis. Altogether, 16 905 cases of multiple sclerosis were identified in the study cohort, 578 among first-generation and 106 among second-generation immigrants. Multiple sclerosis risk among first-generation immigrants whose parents were born in low, intermediate and high multiple sclerosis risk areas were 21% (RR = 0.21; 95% CI: 0.16-0.28), 43% (RR = 0.43; 95% CI: 0.36-0.50) and 75% (RR = 0.75; 95% CI: 0.67-0.83), respectively, of that among ethnic Danes (test for trend P < 0.0001). First-generation immigrants arriving in Denmark before age 15 years had a multiple sclerosis risk higher than that in their country of birth but lower than that in Denmark, reaching on average 69% of the multiple sclerosis risk among ethnic Danes (RR = 0.69; 95% CI: 0.55-0.87). Multiple sclerosis risk among individuals who came to Denmark at a later age remained closer to that of their country of birth, corresponding to 45% of the multiple sclerosis risk among ethnic Danes (RR = 0.45; 95% CI: 0.41-0.49). Our study supports the idea that environmental factors exerting their role in childhood or adolescence may be of aetiological relevance in multiple sclerosis.