Chocolate has been a delicacy for much longer than previously thought.
Botanical evidence shows the plant from which chocolate is made was first grown for food more than 5,000 years ago in the Amazon rainforest.
Chemical residues found on ancient pottery suggest cocoa was used as a food, drink or medicine by indigenous people living in what is now Ecuador.
Until now it was thought that chocolate originated much later and in Central rather than South America.
"The plant was first used at least 1,500 years earlier than we had previous evidence for," said Prof Michael Blake of the department of Anthropology at the University of British Columbia in Vancouver, a co-researcher on the study.
"And that previous evidence was found in Mexico and Central America."
Facts about the cocoa tree
- Grows naturally in humid, tropical forests and is native to Mexico, Central America and northern South America
- The fruit - the cocoa pod - contains seeds surrounded by a white pulp. When the seeds are dried in the sun they turn a brownish colour and are known as cocoa beans
- The ingredients for chocolate - cocoa powder and cocoa butter - are prepared from fermented and roasted cocoa seeds
- Cocoa products are also used widely in pharmaceutical preparations and skin-care products
- In 2008-2009 world cocoa production was 3,515,000 tonnes.
Researchers analysed pottery vessels from the Santa Ana (La Florida) archaeological site in the highlands of Ecuador, which was occupied between 5,300 and 2,100 years ago.
A number of crops have been documented there, including corn, sweet potatoes and the cacao tree Theobroma cacao.
Traces of chemicals and DNA from the plant were found on pottery, suggesting the ground seeds of the cocoa pod were being mixed into a concoction and drunk.
Co-researcher, Dr Sonia Zarrillo of the University of Calgary said grains of starch on the pot appeared to be "unique" to the cacao tree.
The study corroborates DNA data pointing to the tree's origin in the upper Amazon region of northwest South America, which is where the domestic crop also originated.
"It's another gift of the people of Amazonia to the world," said Prof Blake. "It highlights the importance of protecting this habitat."
It is thought that seedlings or seeds of the cocoa tree were carried north into Mexico and Central America, perhaps along sea routes.
Cocoa beans became precious commodities, used as food and drink by the wealthy, or traded for other foods.
Spanish explorers in the 1520s took the cocoa beans home and spread the delicacy throughout Europe.