The sinus node (or sinoatrial node [SAN]), the pacemaker of the heart, is a functionally and structurally heterogeneous tissue, which consists of a large "head" within the right caval vein myocardium and a "tail" along the terminal crest. Here, we investigated its cellular origin and mechanism of formation. Using genetic lineage analysis and explant assays, we identified T-box transcription factor Tbx18-expressing mesenchymal progenitors in the inflow tract region that differentiate into pacemaker myocardium to form the SAN. We found that the head and tail represent separate regulatory domains expressing distinctive gene programs. Tbx18 is required to establish the large head structure, as seen by the existence of a very small but still functional tail piece in Tbx18-deficient fetuses. In contrast, Tbx3-deficient embryos formed a morphologically normal SAN, which, however, aberrantly expressed Cx40 and other atrial genes, demonstrating that Tbx3 controls differentiation of SAN head and tail cardiomyocytes but also demonstrating that Tbx3 is not required for the formation of the SAN structure. Our data establish a functional order for Tbx18 and Tbx3 in SAN formation, in which Tbx18 controls the formation of the SAN head from mesenchymal precursors, on which Tbx3 subsequently imposes the pacemaker gene program.