The segment polarity genes hedgehog and engrailed are expressed in identical posterior-compartment-specific patterns in both Drosophila embryos and imaginal discs. We show here that the hedgehog protein is secreted, and it can cross embryo parasegment borders and the anterior-posterior compartment border of imaginal discs to neighboring cells that express neither engrailed nor hedgehog. In these cells, it is localized in discrete punctate structures that are sequestered within the polarized epithelium. Analysis of animals that have expressed hedgehog ectopically, or of a mutant that expresses hedgehog abnormally in the anterior compartment of the wing disc, indicates that hedgehog is involved in regulating patched. In the embryo, hedgehog regulation of patched apparently facilitates patched and wingless expression. In the discs, hedgehog regulation of patched and other genes in the anterior compartment helps to establish the proximodistal axis. We propose that the cell-cell communication mediated by hedgehog links the special properties of compartment borders with specification of the proximodistal axis in imaginal development.