The genetic mechanisms controlling organ shape are largely unknown. We show that the Drosophila grain gene is required during development for shaping the adult legs and the larval posterior spiracles. Mutant legs are short and wide rather than long and thin, while the spiracles are flat instead of dome-shaped. We demonstrate that grain encodes the GATAc transcription factor. Analysis of loss-of-function mutations at the cellular level indicates that grain affects organ shape by locally controlling cell rearrangement. Ectopic grain expression causes major morphogenetic movements, resulting in the invagination of the posterior segments into the embryo. This is the first gene that has been shown to affect epithelial morphogenesis by controlling cell rearrangements, and suggests a novel function for GATA transcription factors.