After an emotional debate Germany’s parliament has voted by a wide margin to legalise same-sex marriage.

The surprise vote comes after chancellor Angela Merkel — who will seek a fourth term in a national election on 24 September — dropped her longstanding opposition to a free vote on the issue, freeing members of her ruling conservative bloc to follow their personal conscience rather than the party line.

The bill was backed by 393 votes to 226, with four abstentions.

The bill gives homosexual couples in Germany the same rights as heterosexual couples, and will allow same-sex couples to marry and jointly adopt children. 

Most Germany parties had come out strongly in favour of the change to the law before and a recent survey by the government’s anti-discrimination agency found that 83 percent of Germans were in favour of marriage equality.

Martin Schulz, leader of the Social Democratic Party (SPD) — the second largest party in parliament — tweeted his support for the bill.

The bill now goes to the Bundesrat — Germany’s upper house — next week, where is is widely expected to pass and be signed into law some time after 7 July.

Germany joins France, Britain, and Spain, amongst other European countries, in legalising same-sex marriage.

Have Merkel’s views changed?

Not really — she voted against it.

Merkel told reporters after the landmark decision that she had voted against the measure because she believed that marriage as defined under German law was between a man and a woman.

But she said her decision was a personal one, adding that she had become convinced in recent years that same-sex couples should be allowed to adopt children after having dinner with a lesbian couple in her constituency who were foster parents to eight children.

The German leader said:

I hope that the vote today not only promotes respect between the different opinions but also brings more social cohesion and peace. For me and the basic law, it’s about the marriage of a woman and a man. That’s why I voted against it.

Merkel argued against gay marriage on the grounds of children’s welfare during her 2013 election campaign and she admitted she had a “hard time” with the issue.

However, in an on-stage interview with the women’s magazine Brigitte earlier this week she said she would allow a free vote at an unspecified time in the future.