Variation in the size and number of axial segments underlies much of the diversity in animal body plans. Here, we investigate the evolutionary, genetic, and developmental mechanisms driving tail-length differences between forest and prairie ecotypes of deer mice (Peromyscus maniculatus). We first show that long-tailed forest mice perform better in an arboreal locomotion assay, consistent with tails being important for balance during climbing. The long tails of these forest mice consist of both longer and more caudal vertebrae than prairie mice. Using quantitative genetics, we identify six genomic regions that contribute to differences in total tail length, three of which associate with vertebra length and the other three with vertebra number. For all six loci, the forest allele increases tail length, consistent with the cumulative effect of natural selection. Two of the genomic regions associated with variation in vertebra number contain Hox gene clusters. Of those, we find an allele-specific decrease in Hoxd13 expression in the embryonic tail bud of long-tailed forest mice, consistent with its role in axial elongation. Additionally, we find that forest embryos have more presomitic mesoderm than prairie embryos, and that this correlates with an increase in the number of neuromesodermal progenitors (NMPs), which are modulated by Hox13 paralogs. Together, these results suggest a role for Hoxd13 in the development of natural variation in adaptive morphology on a microevolutionary timescale.