Scientists have discovered the specific mutation that famously turned moths black during the Industrial Revolution.
In an iconic evolutionary case study, a black form of the peppered moth rapidly took over in industrial parts of the UK during the 1800s, as soot blackened the tree trunks and walls of its habitat.
Now, researchers from the University of Liverpool have pinpointed the genetic change that caused this adaptation.
They have also calculated the most likely date for the mutation - 1819.
Dr Ilik Saccheri has been working on the peppered moth since setting up his Liverpool laboratory 15 years ago, he told Science in Action on the BBC World Service.
"When I started working on it I was surprised, given how well known it is, that no-one had actually tried to... characterise the underlying genetics controlling the physical appearance of this moth," he said.
"It's a graphic example of rapid evolutionary change. In the days before we could track mutation and change in bacteria and viruses, there weren't many examples of visible change within a human lifetime."
And it was indeed an early discovery; black moths, strikingly different from the insect's usual mottled white, were first spotted in 1848 - 10 years before the concept of natural selection was formally outlined by Darwin and Wallace.
Peppered moths are nocturnal and spend their days dozing on tree trunks or walls, so this new "carbonaria" colouring gave them a much better chance of hiding from hungry birds in the smoke-stained world of industrial England.
"Unfortunately, there weren't people recording the rise in frequency in the latter part of the 1800s. But the next record, which is around 1900 in the Manchester region, indicates that it's almost completely replaced the light-coloured form," said Dr Saccheri.
"The typical form… didn't go extinct; it just went to very low frequencies in cities. But it still remained as the common form in the countryside."
Then from the 1960s onward, clean air laws came into effect and the speckled "typica" variety saw a resurgence.
To zero in on the gene behind this so-called "industrial melanism", Dr Saccheri's team started with traditional genetic mapping. They crossed black and pale moths in the lab and tracked which genetic "markers", dotted along each chromosome, seemed to be linked to the black colouring.
This focussed their attention on a stretch of the moth genome containing 400,000 bases, the individual links in the chain of DNA.
"We knew that within that 400,000 bases, there was some sequence that had to... cause the actual difference between the black type and the typical type," Dr Saccheri explained.
"So we went about an excruciatingly tedious process of identifying every single difference between the two types."
Once there was a final shortlist of 87 DNA differences between the black and pale lab moths, he and his colleagues tested whether each variation, one by one, was present in the wider variety of white moths found in the wild.
"After a long time we eventually managed to get down to a single one, which then had to be the causal mutation. To our surprise, it also turned out to be a rather unusual type of mutation."
The carbonaria mutation was in fact a "jumping" piece of DNA, called a transposon, which had inserted itself into a gene called cortex.
These odd sequences more often have a damaging effect when they disrupt an existing gene. But for one embryonic moth in the early 19th Century, when these extra 9,000 bases landed in its cortex gene, they were in fact the secret to success.
Exactly how the mutation causes black colouring remains a mystery; cortex is not a gene with any known role in pigmentation.
But with some more genetic sleuthing, the team did manage to estimate when that first lucky moth probably hatched. They used the fact that the genome, over time, gets scrambled around as pieces switch between chromosomes in a process called "recombination". A close look at the stretches right next to the cortex mutation showed very little scrambling; this was a recent event.
"You can take a sample of chromosomes in the present population, identify all the sequence variance around the mutation, and infer… the number of generations that it would take for that amount of scrambling to occur in the flanking sequence," explained Dr Sacchieri.
Specifically, they estimate the DNA jump happened in a 10-year window centred on 1819 - a date that fits perfectly with a gradual spread of the mutation through the population, until black moths were first spotted in 1848.
Same gene every time
Prof James Mallet, an expert on butterfly and moth genetics from Harvard University and University College London, was full of praise for the Liverpool team.
"This is an incredible piece of work," he said, adding that the reason it has taken so long to find the culprit gene is because of the sheer difficulty of the experiments.
"These have been incredibly difficult animals to work with. It's not easy as a lab animal, it's hard to breed - it has one generation a year - and it has really limited polymorphism. So it's very hard to use standard genetic techniques to map the genes and locate them on the chromosomes."
The second Nature paper concerned with the cortex gene explores its role in the Heliconius family of tropical butterflies.
Dr Nicola Nadeau from the University of Sheffield was the first author of that study. "It's amazing that the same gene controls such a diversity of different colours and patterns in butterflies and a moth," she said.
Her findings implicate cortex in the Heliconius butterflies' unusual habit of exchanging DNA and mimicking each other's dramatic colouring, which helps ward off predators.
Dr Nadeau's co-author Prof Chris Jiggins, from the University of Cambridge, said it was surprising - and important - to discover a single gene playing such different roles.
"For the moths, the dark colouration developed because they were trying to hide, but the butterflies use bright colours to advertise their toxicity to predators. It raises the question that given the diversity in butterflies and moths, and the hundreds of genes involved in making a wing, why is it this one every time?"
Follow Jonathan on Twitter