The C. elegans foregut (pharynx) has emerged as a powerful system to study organ formation during embryogenesis. Here I review recent advances regarding cell-fate specification and epithelial morphogenesis during pharynx development. Maternally-supplied gene products function prior to gastrulation to establish pluripotent blastomeres. As gastrulation gets under way, pharyngeal precursors become committed to pharyngeal fate in a process that requires PHA-4/FoxA and the Tbox transcription factors TBX-2, TBX-35, TBX-37 and TBX-38. Subsequent waves of gene expression depend on the affinity of PHA-4 for its target promoters, coupled with combinatorial strategies such as feed-forward and positive-feedback loops. During later embryogenesis, pharyngeal precursors undergo reorganization and a mesenchymal-to-epithelial transition to form the linear gut tube. Surprisingly, epithelium formation does not depend on cadherins, catenins or integrins. Rather, the kinesin ZEN-4/MKLP1 and CYK-4/RhoGAP are critical to establish the apical domain during epithelial polarization. Finally, I discuss similarities and differences between the nematode pharynx and the vertebrate heart.