German MPs have voted to legalise same-sex marriage days after Chancellor Angela Merkel gave the go-ahead for a free vote.
The Chancellor voted against the measure, but she paved the way for its passage by freeing other members of her party to vote "with their conscience".
The reform would give gay men and lesbians full marital rights, and allow them to adopt children.
Members of the Bundestag in Berlin voted 393 for legalising "marriage for everybody" and 226 against, with four abstentions.
Germany has allowed same-sex couples to enter civil partnerships since 2001, but same-sex marriages remained illegal.
Mrs Merkel said on Monday that MPs could take up the issue as a "question of conscience", allowing members of her conservative coalition, which has opposed same-sex marriage, to vote individually for it.
The Chancellor voted against the measure because she believes the country's law sees it as between a man and a woman, but that the opposite view must be respected.
The snap vote took place in the German parliament's last regular session before elections on September 24.
While some in Mrs Merkel's conservative bloc spoke against the measure, Berlin Christian Democrat Jan-Marco Luczak urged his fellow party members to back it.
"It would be absurd to try and protect marriage by preventing people to marry," he said.
Mrs Merkel said: "For me marriage as defined by the law is the marriage of a man and a woman".
The measure, which is expected to see legal challenges, also opens the door for gay couples to adopt - which Mrs Merkel says she supports.