Posttranslational modifications of proteins regulate many biological processes, including metabolism, signal transduction, and gene expression. The synthetic challenges associated with generating homogeneous populations of selectively modified proteins, however, have hindered detailed studies of the effects of these modifications on protein structure and function. Here, we report an approach to the cotranslational synthesis of selectively glycosylated proteins in which the modified amino acid is genetically encoded. We show that myoglobin containing beta-N-acetylglucosamine (GlcNAc)-serine at a defined position can be expressed in Escherichia coli in good yield and with high fidelity. The beta-GlcNAc moiety can be recognized by a saccharide-binding protein, or subsequently modified with a galactosyltransferase to build more complex carbohydrates. This approach should be generally applicable to other posttranslational modifications such as protein phosphorylation, acetylation, and methylation.