Flexible joints separate the rigid sections of the insect leg, allowing them to move. In Drosophila, the initial patterning of these joints is apparent in the larval imaginal discs from which the adult legs will develop. Here, we describe the later patterning and morphogenesis of the joints, which occurs after pupariation (AP). In the tibial/tarsal joint, the apodeme insertion site provides a fixed marker for the boundary between proximal and distal joint territories (the P/D boundary). Cells on either side of this boundary behave differently during morphogenesis. Morphogenesis begins with the apical constriction of distal joint cells, about 24 h AP. Distal cells then become columnar, causing distal tissue nearest the P/D boundary to fold into the leg. In the last stage of joint morphogenesis, the proximal joint cells closest to the P/D boundary align and elongate to form a "palisade" (a row of columnar cells) over the distal joint cells. The proximal and distal joint territories are characterised by the differential organisation of cytoskeletal and extracellular matrix proteins, and by the differential expression of enhancer trap lines and other gene markers. These markers also define a number of more localised territories within the pupal joint.