Differentiated neurons balance the need to maintain a stable identity with their flexible responses to dynamic environmental inputs. Here we characterize these opposing influences on gene expression in Caenorhabditis elegans olfactory neurons. Using transcriptional reporters that are expressed differentially in two olfactory neurons, AWC(ON) and AWC(OFF), we identify mutations that affect the long-term maintenance of appropriate chemoreceptor expression. A newly identified gene from this screen, the conserved transcription factor hmbx-1, stabilizes AWC gene expression in adult animals through dosage-sensitive interactions with its transcriptional targets. The late action of hmbx-1 complements the early role of the transcriptional repressor gene nsy-7: Both repress expression of multiple AWC(OFF) genes in AWC(ON) neurons, but they act at different developmental stages. Environmental signals are superimposed onto this stable cell identity through at least two different transcriptional pathways that regulate individual chemoreceptor genes: a cGMP pathway regulated by sensory activity, and a daf-7 (TGF-beta)/daf-3 (SMAD repressor) pathway regulated by specific components of the density-dependent C. elegans dauer pheromone.