Segments are fundamental units in animal development which are made of distinct cell lineages separated by boundaries. Although boundaries show limited plasticity during their formation for sharpening, cell lineages make compartments that become tightly restricted as development goes on. Here, we characterize a unique case of breaking of the segment boundary in late drosophila embryos. During dorsal closure, specific cells from anterior compartments cross the segment boundary and enter the adjacent posterior compartments. This cell mixing behaviour is driven by an anterior-to-posterior reprogramming mechanism involving de novo expression of the homeodomain protein Engrailed. Mixing is accompanied by stereotyped local cell intercalation, converting the segment boundary into a relaxation compartment important for tension-release during morphogenesis. This process of lineage switching and cell remodelling is controlled by JNK signalling. Our results reveal plasticity of segment boundaries during late morphogenesis and a role for JNK-dependent developmental reprogramming in this process.