A single gene could explain much of the size difference between dog breeds, according to a study.
Dogs show the greatest variation in size of all mammals
The domestic dog (Canis familiaris) shows the greatest range of body size of any mammal.
Researchers studied 3,000 dogs from 143 breeds and found small dogs all shared a mutation in a gene that influences size in other animals.
This form of the gene was almost absent in large dog breeds, an international team reported in Science journal.
The 14 small dogs in the sample, such as Portuguese water dogs, chihuahuas, fox terriers and pomeranians, share a specific sequence of DNA that includes the gene for making a hormone called insulin-like growth factor 1 (IGF-1).
The scientists also looked at DNA from nine large breeds including Irish wolfhounds, St Bernards and Great Danes.
The IGF-1 gene has been known to influence size in other organisms, including mice and humans.
Dr Carlos Bustamante, a member of the research team from Cornell University in Ithaca, US, said: "It is staggering to think that so many of the small dog breeds came about through selection on the same mutation in the same gene.
"These results suggest that while there are invariably differences among breeds - even in genes for size - IGF-1 has played an important role in the evolution of many small breeds by being a gene that consistently affects body size."
Small dogs may have appeared more than 10,000 years ago
The new research suggests that a mutation in this gene led to the appearance of small dogs more than 10,000 years ago.
Over the several thousand years that ensued, selective dog-breeding ensured the dog gene was kept around and spread through human migration and trade.
All domestic dogs are descended from wolves. They were the first animals to be domesticated more than 15,000 years ago, although early humans and wolves may have co-existed for about 400,000 years.
While wolves tend to look the same, today's dog breeds come in a huge variety of shapes and sizes.
The genetic origin of this diversity has long puzzled scientists, especially the size differences.
"We know this is only part of the story, but it's a necessary part of the story," said Elaine Ostrander of the National Human Genome Research Institute in Bethesda, US, an author on the Science paper.
She noted there were a few exceptions, with the small-dog sequence appearing in larger dogs. Other, as yet-unidentified genetic factors must cause the exceptions.
Dr Ostrander said the research could assist the understanding of cancer and other disorders of growth.