Microbial production of chemicals is now an attractive alternative to chemical synthesis. Current efforts focus mainly on constructing pathways to produce different types of molecules. However, there are few strategies for engineering regulatory components to improve product titers and conversion yields of heterologous pathways. Here we developed a dynamic sensor-regulator system (DSRS) to produce fatty acid-based products in Escherichia coli, and demonstrated its use for biodiesel production. The DSRS uses a transcription factor that senses a key intermediate and dynamically regulates the expression of genes involved in biodiesel production. This DSRS substantially improved the stability of biodiesel-producing strains and increased the titer to 1.5 g/l and the yield threefold to 28% of the theoretical maximum. Given the large number of natural sensors available, this DSRS strategy can be extended to many other biosynthetic pathways to balance metabolism, thereby increasing product titers and conversion yields and stabilizing production hosts.