Fruit flies can be a scourge in our homes, but to date no-one has known how they became our uninvited lodgers. For decades, researchers have searched for their origins and now a Swedish-American research team has succeeded. They have also discovered that fruit flies in the wild are far more picky than their domesticated counterparts, a factor that long ago probably prompted the flies to move in with people.

"The ancestors of the flies in our fruit bowls lived in southern Africa. About 10,000 years ago they moved in with their neighbours: humans. Their offspring then colonised the world. It's actually quite awesome," says Marcus Stensmyr, senior lecturer at Lund University.

It was in the forests of what is now Zambia and Zimbabwe that the researchers after several years of searching have found clues to the background of the fruit fly, Drosophila melanogaster. Within science, it has been perhaps the most studied organism ever, but even so no-one had ever discovered them in the wild, or uncovered where they came from.

With the help of traps, Marcus Stensmyr and colleagues from Lund and the University of Wisconsin-Madison succeeded in capturing fruit flies in the African forests. Traps close to marula fruit were quickly filled with flies, while traps at other locations remained empty or only attracted a few flies.

The researchers already knew that overripe, rotten, citrus fruits are the fruit flies' favourite in the fruit bowl. They therefore tested what the flies preferred in the wild: marula or citrus. The answer: marula. They got the same results when testing fruit flies in other parts of the world, flies that had never previously been anywhere near marula.

"At home in the kitchen the flies feast on whatever is starting to rot in the fruit bowl, even though they like citrus fruits best. In the wild they are far more picky, they prefer marula fruit," says Marcus Stensmyr.

"They are drawn to particular aromatic substances from marula that activate receptors on the antennae. When these are activated, it's a sign that it's a good place to lay eggs."

However, marula have not only been liked by fruit flies through the millennia. Archaeological finds have shown that the San people, one of the indigenous tribes in the investigated area, have had a special relationship with marula fruit throughout history. In one cave, archaeologists found more than 24 million walnut-sized marula pips.

The researchers' conclusion is that the San people's love of marula fruit explains why the fruit flies moved in with people long ago. Over time the flies adjusted to living inside and became increasingly tolerant to ethanol in rotten fruit.

"The fly has developed into a generalist that eats and breeds in all sorts of fruit. But originally it was a real specialist that only lived where there was marula fruit," concludes Marcus Stensmyr.