The embryonic dorsal vessel in Drosophila possesses anteroposterior polarity and is subdivided into two chamber-like portions, the aorta in the anterior and the heart in the posterior. The heart portion features a wider bore as compared with the aorta and develops inflow valves (ostia) that allow the pumping of hemolymph from posterior toward the anterior. Here, we demonstrate that homeotic selector genes provide positional information that determines the anteroposterior subdivision of the dorsal vessel. Antennapedia (Antp), Ultrabithorax (Ubx), abdominal-A (abd-A), and Abdominal-B (Abd-B) are expressed in distinct domains along the anteroposterior axis within the dorsal vessel, and, in particular, the domain of abd-A expression in cardioblasts and pericardial cells coincides with the heart portion. We provide evidence that loss of abd-A function causes a transformation of the heart into aorta, whereas ectopic expression of abd-A in more anterior cardioblasts causes the aorta to assume heart-like features. These observations suggest that the spatially restricted expression and activity of abd-A determine heart identities in cells of the posterior portion of the dorsal vessel. We also show that Abd-B, which at earlier stages is expressed posteriorly to the cardiogenic mesoderm, represses cardiogenesis. In light of the developmental and morphological similarities between the Drosophila dorsal vessel and the primitive heart tube in early vertebrate embryos, these data suggest that Hox genes may also provide important anteroposterior cues during chamber specification in the developing vertebrate heart.