Regulation of gene expression in response to the changing environment is critical for cell survival. For instance, binding of macrolide antibiotics to the ribosome promotes translation arrest at the leader open reading frames ermCL and ermBL, which is necessary for inducing the antibiotic resistance genes ermC and ermB. Cladinose-containing macrolides such as erythromycin (ERY), but not ketolides such as telithromycin (TEL), arrest translation of ermCL, whereas either ERY or TEL stall ermBL translation. How the ribosome distinguishes between chemically similar small molecules is unknown. We show that single amino acid changes in the leader peptide switch the specificity of recognition of distinct molecules, triggering gene activation in response to ERY alone, to TEL alone or to both antibiotics or preventing stalling altogether. Thus, the ribosomal response to chemical signals can be modulated by minute changes in the nascent peptide, suggesting that protein sequences could have been optimized for rendering translation sensitive to environmental cues.