The genetic code underlying protein synthesis is a canonical example of a degenerate biological system. Degeneracies in physical and biological systems can be lifted by external perturbations thus allowing degenerate systems to exhibit a wide range of behaviors. Here we show that the degeneracy of the genetic code is lifted by environmental perturbations to regulate protein levels in living cells. By measuring protein synthesis rates from a synthetic reporter library in Escherichia coli, we find that environmental perturbations, such as reduction of cognate amino acid supply, lift the degeneracy of the genetic code by splitting codon families into a hierarchy of robust and sensitive synonymous codons. Rates of protein synthesis associated with robust codons are up to hundred-fold higher than those associated with sensitive codons under these conditions. We find that the observed hierarchy between synonymous codons is not determined by usual rules associated with tRNA abundance and codon usage. Rather, competition among tRNA isoacceptors for aminoacylation underlies the robustness of protein synthesis. Remarkably, the hierarchy established using the synthetic library also explains the measured robustness of synthesis for endogenous proteins in E. coli. We further found that the same hierarchy is reflected in the fitness cost of synonymous mutations in amino acid biosynthesis genes and in the transcriptional control of sigma factor genes. Our study reveals that the degeneracy of the genetic code can be lifted by environmental perturbations, and it suggests that organisms can exploit degeneracy lifting as a general strategy to adapt protein synthesis to their environment.