A theory for analysis and prediction of spatial and temporal patterns of gene and protein expression within microbial biofilms is derived. The theory integrates phenomena of solute reaction and diffusion, microbial growth, mRNA or protein synthesis, biomass advection, and gene transcript or protein turnover. Case studies illustrate the capacity of the theory to simulate heterogeneous spatial patterns and predict microbial activities in biofilms that are qualitatively different from those of planktonic cells. Specific scenarios analyzed include an inducible GFP or fluorescent protein reporter, a denitrification gene repressed by oxygen, an acid stress response gene, and a quorum sensing circuit. It is shown that the patterns of activity revealed by inducible stable fluorescent proteins or reporter unstable proteins overestimate the region of activity. This is due to advective spreading and finite protein turnover rates. In the cases of a gene induced by either limitation for a metabolic substrate or accumulation of a metabolic product, maximal expression is predicted in an internal stratum of the biofilm. A quorum sensing system that includes an oxygen-responsive negative regulator exhibits behavior that is distinct from any stage of a batch planktonic culture. Though here the analyses have been limited to simultaneous interactions of up to two substrates and two genes, the framework applies to arbitrarily large networks of genes and metabolites. Extension of reaction-diffusion modeling in biofilms to the analysis of individual genes and gene networks is an important advance that dovetails with the growing toolkit of molecular and genetic experimental techniques.