Scientists admitted to being surprised by the discovery, which indicates that even insects show signs of intelligence.
Gathering information before deciding on a course of action was previously thought to be the preserve of highly evolved species, such as monkeys and humans.
In a series of tests, the researchers asked fruit flies to distinguish between ever closer concentrations of an odour they were trained to avoid. When the concentrations were very different and easy to tell apart, flies acted quickly to move to the end of a chamber furthest away from the strongest smell.
But when they were very close and difficult to distinguish, the flies took much longer to make a decision, and made more mistakes.
Instead of acting on impulse, they seemed to weigh up information before making a choice.
Professor Gero Miessenbock, of Oxford University's Centre for Neural Circuits and Behaviour, said: "Our findings show fruit flies have a surprising mental capacity that has previously been unrecognised."