Parliament on Tuesday voted resoundingly to legalize same-sex marriages in South Africa , making the nation the first in Africa and the fifth in the world to remove legal barriers to them , according to advocates .