Walking to work is also good for you, although it does not offer the same benefits as taking a bike, experts from the University of Glasgow found.
The new study on 264,337 people, 52% of whom were women, found cycling to work is linked to a 45% lower risk of developing cancer and a 46% lower risk of cardiovascular disease, compared to driving to work or taking public transport.
Overall, cyclists had a 41% lower risk of premature death from any cause.
Walking to work was also associated with a 27% lower risk of developing cardiovascular disease and a 36% lower risk of dying from it.
But there was no link with a lower risk of cancer or dying early from any cause in walkers, the study found.
People who preferred to stroll to work also had to walk for two hours a week in total to see health benefits, at an average speed of three miles per hour.
Experts behind the study, published in the British Medical Journal (BMJ), said the lower benefits seen for walking compared to cycling could be down to several factors.
These include the fact cyclists covered longer distances in their commutes than the walkers, cycling is a higher intensity exercise and cyclists were generally more fit.
Dr Carlos Celis-Morales, from the University of Glasgow, said: "Walking to work was associated with lower risk of heart disease, but unlike cycling was not associated with a significantly lower risk of cancer or overall death.
"This may be because walkers commuted shorter distances than cyclists, typically six miles per week, compared with 30 miles per week, and walking is generally a lower intensity of exercise than cycling."
The study also found some health benefits if people cycled part of their journey and took public transport or drove the rest of the way.
The people taking part in the research were aged 52 on average at the start of the study and were followed for five years.
About 2,430 people died during the study period, with 496 deaths related to cardiovascular disease, which covers all diseases of the heart and circulation, and 1,126 deaths from cancer.
Overall, 3,748 people developed cancer over the five years, and 1,110 had an event related to cardiovascular disease, such as a heart attack or stroke.