Racial segregation is often blamed for some of the achievement gap between blacks and whites. We study the effects of school and neighborhood segregation on the relative SAT scores of black students across different metropolitan areas, using large microdata samples for the 1998-2001 test cohorts. Our models include detailed controls for the family background of individual test-takers, school-level controls for selective participation in the test, and city-level controls for racial composition, income, and region. We find robust evidence that the black-white test score gap is higher in more segregated cities. Holding constant family background and other factors, a shift from a fully segregated to a completely integrated city closes about one-quarter of the raw black-white gap in SAT scores. Specifications that distinguish between school and neighborhood segregation suggest that neighborhood segregation has a consistently negative impact but that school segregation has no independent effect (though we cannot reject equality of the two effects). We find similar results using Census-based data on schooling outcomes for youth in different cities. Data on enrollment in honors courses suggest that within-school segregation increases when schools are more highly integrated, potentially offsetting the benefits of school desegregation and accounting for our findings.