We examine the effect of single-sex classes on the pass rates, grades, and continued enrollment 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 studies on single-sex education done on students in primary and secondary school. 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 8% higher overall. Furthermore, females in all-females classes are roughly 9% more likely to continue studying economics and business at university than females who studied in coed classes. There is evidence that single-sex education causes women to adopt behaviors associated with better academic outcomes: such as attending more classes and doing optional assignments. However, these behavioral changes can explain, at most 40% of the all-female effect, suggesting that there is a large direct effect of single-sex education on outcomes.