Sunbathing, which causes skin cancer, can also help to fight the disease, finds two new studies.
Scientists say, although, protection from sunlight is necessary, moderate exposure is beneficial to health.
A joint team of researchers from Leeds University and the US National Institutes of Health found the high level of vitamin D produced due to high exposure to sunlight helped malignant melanoma patients to fight the deadly skin cancer.
The study found that those with the lowest levels of the vitamin D in their blood at the time of diagnosis were 30 per cent more likely to suffer a recurrence of the disease after treatment than those who had the highest levels.
The findings of the research have been published in the Journal of the National Cancer Institute.
The Independent quoted the team leader of the melanoma study, Professor Julia Newton Bishop, as saying: "It is common for people to have low levels of vitamin D in many countries. Melanoma patients tend to avoid the sun as sunburn is known to increase the risk of the disease.
"Our results suggest that melanoma patients may need to get vitamin D by eating fatty fish or by taking supplements to ensure they have normal levels."
However scientists also warned about the excess intake of vitamin D.
Professor Newton said: "There is some evidence from other studies that high levels of vitamin D are also harmful. So we should aim for a normal level rather than a very high one."
Professor Kimmie Ng, from the Dana-Farber Cancer Institute in Boston, US, led the second study.
This team observed over 1,000 bowel cancer patients for nine years, and concluded those with highest vitamin D levels had 50 percent more survival chances than those with lowest levels.
The report has been published in the British Journal of Cancer.
The study was funded by at Cancer Research UK.
Sara Hiom, the director of health information at the research center said: "The key is to get the right balance between the amount of time spent in the sun and the levels of vitamin D needed for good health.
"Protection from burning in the sun is still vital. People with lots of moles, red hair, fair skin and a family history of the disease should take extra care as they are more at risk."