This paper estimates peer effects on student achievement using a panel data set from a middle school in China. Unique features of the organization of Chinese middle schools (Grades 7 to 9) and panel data allow us to overcome difficulties that have hindered the separation of peer effects from omitted individual factors due to self-selection and from common teacher effects and to identify peer effects at the classroom level. We estimate peer effects for Math, English, and Chinese test scores separately. In a linear-in-means model controlling for both individual and teacher-by-test fixed effects, peers are found to have a positive and significant effect on math test scores, a positive but insignificant effect on Chinese test scores, but no effect on English test scores. Importantly, in Math and Chinese students at the middle of the ability distribution tend to benefit from better peers, whereas students at the ends of the ability distribution do not, suggesting that policy makers who want to exploit positive peer effects face difficult tradeoffs in classroom and school assignment.