Taking cocaine can change the structure of the brain within hours in what could be the first steps of drug addiction, according to US researchers.
Animal tests, reported in the journal Nature Neuroscience, showed new structures linked to learning and memory began to grow soon after the drug was taken.
Mice with the most brain changes showed a greater preference for cocaine.
Experts described it as the brain "learning addiction".
The team at University of California, Berkeley and UC San Francisco looked for tiny protrusions from brain cells called dendritic spines. They are heavily implicated in memory formation.
The place or environment that drugs are taken plays an important role in addiction.
In the experiments, the mice were allowed to explore freely two very different chambers - each with a different smell and surface texture.
Once they had picked a favourite they were injected with cocaine in the other chamber.
A type of laser microscopy was used to look inside the brains of living mice to hunt for the dendritic spines.
More new spines were produced when the mice were injected with cocaine than with water, suggesting new memories being formed around drug use.
The difference could be detected two hours after the first dose.
Researcher Linda Wilbrecht, assistant professor of psychology and neuroscience at UC Berkeley, said: "Our images provide clear evidence that cocaine induces rapid gains in new spines, and the more spines the mice gain, the more they show they learned about the drug.
"This gives us a possible mechanism for how drug use fuels further drug-seeking behaviour.
"These drug-induced changes in the brain may explain how drug-related cues come to dominate decision making in a human drug user."
Commenting on the research, Dr Gerome Breen, from the Institute of Psychiatry at King's College London, told the BBC: "Dendritic spine development is particularly important in learning and memory.
"This study gives us a solid understanding of how addiction occurs - it shows us how addiction is learned by the brain.
"But it is not immediately apparent how useful this would be in developing a therapy."