In most organisms, primordial germ cells (PGCs) arise far from the region where somatic gonadal precursors (SGPs) are specified. Although PGCs in general originate as a single cluster of cells, the somatic parts of the gonad form on each site of the embryo. Thus, to reach the gonad, PGCs not only migrate from their site of origin but also split into two groups. Taking advantage of high-resolution real-time imaging, we show that in Drosophila melanogaster PGCs are polarized and migrate directionally toward the SGPs, avoiding the midline. Unexpectedly, neither PGC attractants synthesized in the SGPs nor known midline repellents for axon guidance were required to sort PGCs bilaterally. Repellent activity provided by wunen (wun) and wunen-2 (wun-2) expressed in the central nervous system, however, is essential in this migration process and controls PGC survival. Our results suggest that expression of wun/wun-2 repellents along the migratory paths provides faithful control over the sorting of PGCs into two gonads and eliminates PGCs left in the middle of the embryo.