Insulin and related peptides play important and conserved functions in growth and metabolism. Although Drosophila has proved useful for the genetic analysis of insulin functions, little is known about the transcription factors and cell lineages involved in insulin production. Within the embryonic central nervous system, the MP2 neuroblast divides once to generate a dMP2 neuron that initially functions as a pioneer, guiding the axons of other later-born embryonic neurons. Later during development, dMP2 neurons in anterior segments undergo apoptosis but their posterior counterparts persist. We show here that surviving posterior dMP2 neurons no longer function in axonal scaffolding but differentiate into neuroendocrine cells that express insulin-like peptide 7 (Ilp7) and innervate the hindgut. We find that the postmitotic transition from pioneer to insulin-producing neuron is a multistep process requiring retrograde bone morphogenetic protein (BMP) signalling and four transcription factors: Abdominal-B, Hb9, Fork Head, and Dimmed. These five inputs contribute in a partially overlapping manner to combinatorial codes for dMP2 apoptosis, survival, and insulinergic differentiation. Ectopic reconstitution of this code is sufficient to activate Ilp7 expression in other postmitotic neurons. These studies reveal striking similarities between the transcription factors regulating insulin expression in insect neurons and mammalian pancreatic beta-cells.