Among‐population variance of phenotypic traits is of high relevance for understanding evolutionary mechanisms that operate in relatively short timescales, but various sources of nonindependence, such as common ancestry and gene flow, can hamper the interpretations. In this comparative analysis of 138 dog breeds, we demonstrate how such confounders can independently shape the evolution of a behavioural trait (human‐directed play behaviour from the Dog Mentality Assessment project). We combined information on genetic relatedness and haplotype sharing to reflect common ancestry and gene flow, respectively, and entered these into a phylogenetic mixed model to partition the among‐breed variance of human‐directed play behaviour while also accounting for within‐breed variance. We found that 75% of the among‐breed variance was explained by overall genetic relatedness among breeds, whereas 15% could be attributed to haplotype sharing that arises from gene flow. Therefore, most of the differences in human‐directed play behaviour among breeds have likely been caused by constraints of common ancestry as a likely consequence of past selection regimes. On the other hand, gene flow caused by crosses among breeds has played a minor, but not negligible role. Our study serves as an example of an analytical approach that can be applied to comparative situations where the effects of shared origin and gene flow require quantification and appropriate statistical control in a within‐species/among‐population framework. Altogether, our results suggest that the evolutionary history of dog breeds has left remarkable signatures on the among‐breed variation of a behavioural phenotype.