Germany's parliament voted by a wide margin on Friday to legalize same-sex marriage after Chancellor Angela Merkel did an about-face that freed members of her ruling conservative bloc to follow their personal conscience rather than the party line.