We examine the effect of single-sex classes on the pass rates, grades, and course choices of students in a coeducational university. We randomly assign students to all-female, all-male, and coed classes and, therefore, get around the selection issues present in other studies on single-sex education. We find that one hour a week of single-sex education benefits females: females are 7.5% more likely to pass their first year courses and score 10% higher in their required second year classes than their peers attending coeducational classes. We find no effect of single-sex education on the subsequent probability that a female will take technical classes and there is no effect of single-sex education for males. Furthermore, we are able to examine potential mechanisms and indirect effects of single-sex education. We find that the effects of single-sex education do not appear to be driven by a tracking mechanism and that there are indirect effects on class attendance and completion of optional assignments for females. However, the indirect effects cannot explain much of the effect of single-sex education for females.