German politicians have voted to legalise same-sex marriage in a snap vote only days after Chancellor Angela Merkel changed her mind to allow a free vote.

Key points: 393 voted in favour of legalising same-sex marriage, 226 against

393 voted in favour of legalising same-sex marriage, 226 against Bill grants same-sex couples full marital rights, including child adoption

Bill grants same-sex couples full marital rights, including child adoption Chancellor Angela Merkel voted against the measure

The move brings Germany into line with many other European nations including France, Britain and Spain, and follows Ms Merkel's surprise decision this week to allow her politicians to follow their own conscience rather than the party line on the issue.

Ms Merkel, who has long opposed same-sex marriage — citing concerns over the welfare of children — voted against the bill.

But she paved the way for the vote after saying on Monday that politicians could take up the issue as a "question of conscience".

The bill will grant gay and lesbian couples full marital rights, including child adoption.

Hundreds of gay activists, some with painted faces, celebrated outside the Bundestag lower house of parliament after the vote, waving rainbow flags and placards that read: "Marriage for all — make love for all."

Demonstrators celebrated outside the lower house of Parliament after the decision. ( Reuters: Hannibal Hanschke )

"This is simply a historic day for Germany," said activist Soeren Landmann.

"Today, thousands of same-sex couples were given equality, and the two-class society in matters of love was abolished. Germany can really rejoice today."

The vote has particular resonance in Germany as it unwinds a legacy of virulent homophobia.

Earlier this year, Parliament agreed to grant compensation to thousands of gay men jailed under a 19th century law that was strengthened by the Nazis and only dropped in 1969 when homosexuality was decriminalised in West Germany.

A total of 393 politicians voted to legalising "marriage for everybody", while 226 voted against and four abstained.

Green Party's gay rights activist Volker Beck celebrates after the vote. ( AP: Michael Sohn )

The move freed members of her conservative coalition to individually vote for it rather than follow party lines.

Ms Merkel said though she voted against legalising gay marriage, she hoped Parliament's approval of the measure would lead to more social cohesion.

"For me, marriage in the basic law is marriage between a man and a woman and that is why I did not vote in favour of this bill today," she said.

Germany has allowed same-sex couples to enter civil partnerships since 2001, but same-sex marriages had remained illegal.

All of Ms Merkel's potential coalition partners after the September 4 election, including the centre-left Social Democrats of her challenger Martin Schulz, have been calling for same-sex marriage to be legalised.

Decision draws ire of conservatives

German Chancellor Angela Merkel voted against the move to legalise same-sex marriage. ( AP: Michael Sohn )

Ms Merkel's announcement that she would allow politicians to vote on same-sex marriage according to their individual conscience drew the ire of some in her traditionally Catholic conservative bloc.

But political analysts say the issue will likely have faded from voters' minds by the time the September election comes around.

The vote marks a rare victory for Ms Merkel's Social Democrat (SPD) coalition partners, who are trailing the conservatives in opinion polls.

They had seized on her surprise comments to say they would push for an early vote before parliament's summer recess.

Success in passing the so-called "marriage for all" amendment could provide a sorely needed boost for the centre-left SPD, which has seen a short-lived boost in the polls earlier this year evaporate in recent months.

The measure will likely be signed into law by the President some time after July 7.

ABC/wires