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.
Some 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.
Dr Jason Gill, from the institute of cardiovascular and medical sciences at Glasgow, said the Government needs to look at ways to make it easier for people to commute by bike, such as creating “cycle lanes, city bike hire, subsidised cycle purchase schemes and increasing provision for cycles on public transport”.
These would create “major opportunities for public health improvement,” he added.
Dr Mike Knapton, associate medical director at the British Heart Foundation, said: “Commuting to work by walking, or better still, cycling, is a great way to combine physical activity into your normal daily routine.
“This study shows that people who cycle to work or walk for two hours a week have a significantly reduced risk of heart attack, stroke, and death.
“It is paramount to make physical activity easier and more accessible if we are to reduce the burden of ill health caused by inactivity. Local authorities and workplaces should support this by making using active transport as a means to get to work an easy option.”