This paper studies the relationship between social class, educational attainment, and social mobility. While educational expansion has been shown to increase educational attainment and social mobility in contemporary countries, the 19th century has received little attention. The German state of Bavaria experienced an enormous expansion of secondary education in the course of the 19th century, also due to the introduction of modern secondary education (Gewerbeschule). In this context, it is asked whether educational expansion (1) led to changes in the association between social class and educational attainment, and especially so after the introduction of the Gewerbeschule; (2) weakened the link between social class of origin (father's occupation) and class of destination (son's occupation) and thereby increased social mobility? Employing a unique dataset based on annual school reports of 21 Bavarian cities covering the 19th century, the analysis of occupational background information on students by the use of HISCO/HISCLASS reveals that introduction of the Gewerbeschule increased self-selection of the upper class into traditional and the middle class into modern education. Even though educational expansion did not increase participation of lower social classes, the prospect of social mobility for underprivileged classes was high especially in the Gymnasium.