Congenital malformations of anorectal and genitourinary (collectively, anogenital) organs occur at a high frequency in humans, however the lineage of cells that gives rise to anogenital organs remains poorly understood. The penile urethra has been reported to develop from two cell populations, with the proximal urethra developing from endoderm and the distal urethra forming from an apical ectodermal invagination, however this has never been tested by direct analysis of cell lineage. During gut development, endodermal cells express Sonic hedgehog (Shh), which is required for normal patterning of digestive and genitourinary organs. We have taken advantage of the properties of Shh expression to genetically label and follow the fate of posterior gut endoderm during anogenital development. We report that the entire urethra, including the distal (glandar) region, is derived from endoderm. Cloacal endoderm also gives rise to the epithelial linings of the bladder, rectum and anterior region of the anus. Surprisingly, the lineage map also revealed an endodermal origin of the perineum, which is the first demonstration that endoderm differentiates into skin. In addition, we fate mapped genital tubercle ectoderm and show that it makes no detectable contribution to the urethra. In males, formation of the urethral tube involves septation of the urethral plate by continued growth of the urorectal septum. Analysis of cell lineage following disruption of androgen signaling revealed that the urethral plate of flutamide-treated males does not undergo this septation event. Instead, urethral plate cells persist to the ventral margin of the tubercle, mimicking the pattern seen in females. Based on these spatial and temporal fate maps, we present a new model for anogenital development and suggest that disruptions at specific developmental time points can account for the association between anorectal and genitourinary defects.