Through their power to sentence, trial judges exercise enormous authority in the criminal justice system. In 39 American states, these judges stand periodically for reelection. Do elections degrade their impartiality? We develop a dynamic theory of sentencing and electoral control. Judges discount the future value of retaining office relative to implementing preferred sentences. Voters are largely uninformed about judicial behavior, so even the outcome of a single publicized case can be decisive in their evaluations. Further, voters are more likely to perceive instances of underpunishment than overpunishment. Our theory predicts that elected judges will consequently become more punitive as standing for reelection approaches. Using sentencing data from 22,095 Pennsylvania criminal cases in the 1990s, we find strong evidence for this effect. Additional tests confirm the validity of our theory over alternatives. For the cases we examine, we attribute at least 1,818 to 2,705 years of incarceration to the electoral dynamic.