The Brazilian Senate has approved a bill that reserves half the places in the country's prestigious federal universities to state school students.
African-Brazilian Senator Paulo Paim said most Brazilians would benefit as only 10% of students graduated from private schools.
President Dilma Rousseff is now expected to sign the bill into law.
But the measure has attracted criticism, as it also sets up quotas based on racial background.
The reserved spots will be distributed among black, mixed race and indigenous students according to the racial make-up of each Brazilian state.
The racial quotas will be discontinued in 10 years.
Brazil has the biggest black population anywhere outside of Nigeria, but private schools are still predominantly white.
Private school students are usually better prepared than pupils from the public school system for the tough university entry exams.
They get most of the places in federal universities, which paradoxically are heavily subsidised and virtually free of charge.
But many argue that a US-style affirmative action policy should not be implemented in Brazil, where most of the population is mixed race.
Brazil is one of the most ethnically diverse countries in the world and many Brazilians regard their nation as a "racial democracy" where there is little overt racism.
Nonetheless black Brazilians, the descendants of African slaves brought over during Portuguese colonial rule, are much more likely to be poor and rarely reach the top levels of business or politics.
Senator Aloysio Nunes, who voted against the bill on Tuesday night, said federal universities are centres of excellence which should select the students with the best marks, regardless of race or class.
"The measure straightjackets universities because it violates their management autonomy," Mr Nunes said.
Senators in favour of the bill argued it would preserve social justice.
President Dilma sanctioned the law today and I'm only posting because the South America and Latin America tags looked like they could benefit from some action.