We use the PISA 2003 student-level achievement database for Mexico to estimate state education production functions. Student characteristics, family background, home inputs, resources and institutions are controlled for. We take advantage of the state-level variation and representative sample to analyze the impact of institutional factors such as state accountability systems and the role of teachers unions on student achievement. Accountability, through increased use of state assessments, will improve learning outcomes. The paper also casts light on the role of teacher unions, namely their strength through appointments to the school and relations with state governments. It is shown that good relations between states and unions are important. Accountability systems are cost-effective measures for improving outcomes.