This paper studies the institutional structure of criminal sentencing, focusing on the interaction between legislatures, which set sentencing ranges ex ante, and judges, who choose actual sentences from within those ranges ex post. The key question concerns the optimal degree of judicial discretion, given the sequential nature of the process and the possibly divergent interests of legislatures and judges regarding the social function of criminal punishment. The enactment of sentencing reform in the 1970s and 80s provides both a context for the model and an opportunity to evaluate its conclusions.