Women with low levels of vitamin D have a 43 percent higher risk of developing multiple sclerosis.
More than 2.3million people around the world have MS, including around 100,000 people in Britain and more than 400,000 in the US.
People normally get diagnosed between the ages of 20 and 40, but it is difficult to identify the crippling condition until symptoms become apparent.
Now, a study by Harvard T.H. Chan School of Public Health says measuring vitamin D levels could denote one's risk - which shows maintaining a healthy amount of the 'sunshine vitamin' is key to preventing MS.
Examining levels of the 'sunshine vitamin' in the blood may help predict whether a person is at risk of developing the crippling condition which affects the central nervous system
Study author Doctor Kassandra Munger said: 'There have only been a few small studies suggesting that levels of vitamin D in the blood can predict risk.
'Our study, involving a large number of women, suggests that correcting vitamin D deficiency in young and middle-age women may reduce their future risk of MS.'
For the study, researchers used a repository of blood samples from more than 800,000 women in Finland, taken as part of prenatal testing.
The researchers then identified 1,092 women who were diagnosed with MS an average of nine years after giving the blood samples. They were compared to 2,123 women who did not develop the disease.
Deficient levels of vitamin D were defined as fewer than 30 nanomoles per litre (nmol/L). Insufficient levels were 30 to 49 nmol/L and adequate levels were 50 nmol/L or higher.
Of the women who developed MS, 58 percent had deficient levels of vitamin D, compared to 52 percent of the women who did not develop the disease.
Researchers found that with each 50 nmol/L increase in vitamin D levels in the blood, the risk of developing MS later in life decreased by 39 percent.
Women who had deficient levels of vitamin D had a 43 percent higher risk of developing MS than women who had adequate levels as well as a 27 percent higher risk than women with insufficient levels.
Dr Mungar added: 'More research is needed on the optimal dose of vitamin D for reducing risk of MS.
'But striving to achieve vitamin D sufficiency over the course of a person's life will likely have multiple health benefits.'
The findings were published in the online issue of the journal Neurology.