Image copyright Getty Images

Your lungs have an almost "magical" ability to repair some of the damage caused by smoking - but only if you stop, say scientists.

The mutations that lead to lung cancer had been considered to be permanent, and to persist even after quitting.

But the surprise findings, published in Nature, show the few cells that escape damage can repair the lungs.

The effect has been seen even in patients who had smoked a pack a day for 40 years before giving up.

The thousands of chemicals in tobacco smoke corrupt and mutate the DNA in your lung cells - slowly transforming them from healthy to cancerous.

The study uncovered that happening on a massive scale in a smoker's lungs even before they had cancer.

Image copyright Getty Images

The overwhelming majority of cells taken from a smoker's airways had been mutated by tobacco, with cells containing up to 10,000 genetic alterations.

"These can be thought of as mini time bombs, waiting for the next hit that causes them to progress to cancer," said Dr Kate Gowers, one of the researchers at UCL.

But a small proportion of cells went unscathed.

Exactly how they avoid the genetic devastation caused by smoking is unclear, but the researchers said they appeared to "exist in a nuclear bunker".

However, after someone quits smoking, it is these cells that grow and replace the damaged cells in the lungs.

In people who quit, up to 40% of their cells looked just like those from people who had never smoked.

"We were totally unprepared for the finding," Dr Peter Campbell, from the Sanger Institute, told BBC News.

He added: "There is a population of cells that, kind of, magically replenish the lining of the airways.

"One of the remarkable things was patients who had quit, even after 40 years of smoking, had regeneration of cells that were totally unscathed by the exposure to tobacco."

Motivation to quit

The researchers still need to assess how much of the lungs are repaired. The study focused on the major airways rather than the small structures called alveoli, where oxygen crosses from the air we breathe into our lungs.

There are about 47,000 cases of lung cancer in the UK each year. Nearly three-quarters of them are caused by smoking.

Studies have already shown that people cut their risk of lung cancer almost from the day they quit.

The assumption had been that this was simply because any further mutations caused by smoking were avoided.

Dr Rachel Orritt, from Cancer Research UK, said: "It's a really motivating idea that people who stop smoking might reap the benefits twice over - by preventing more tobacco-related damage to lung cells, and by giving their lungs the chance to balance out some of the existing damage with healthier cells."

Follow James on Twitter.