Landmark vote comes after Chancellor Angela Merkel changes her mind and tells party members to follow their conscience.

Germany’s parliament has voted by a wide margin to legalise same-sex marriage after Chancellor Angela Merkel changed her mind and said members of her ruling conservative bloc should follow their personal conscience rather than the party line.

The parliament voted by 393 to 226 on Friday in favour of same-sex marriage.

The reform gives full marital rights for same-sex couples and allows them to adopt children.

Merkel, who will seek a fourth term in a national election in September, 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.

READ MORE: Germany’s minor parties – In their own words

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.

“I hope that the vote today not only promotes respect between the different opinions, but also brings more social cohesion and peace,” Merkel said.

‘Marriage for all’

Online, #Ehefueralle (“Marriage for all”) trended worldwide, with many celebrating the amendment.

Everyone should be able to love the person they want to love. Wonderful news from Germany! #Ehefüralle 🏳️‍🌈 pic.twitter.com/vj5l3jlbUa — Guy Verhofstadt (@guyverhofstadt) June 30, 2017

Merkel’s announcement on Monday that she would allow legislators to vote on same-sex marriage according to their individual conscience angered 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.

Friday’s vote, however, still marks a rare victory for Merkel’s Social Democrat (SPD) coalition partners, who are trailing the conservatives in opinion polls.

Success in passing the “marriage for all” amendment could provide a sorely needed boost for the centre-left SPD, which has seen a short-lived gain 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.

Many other European countries, including France, Britain and Spain, have already legalised same-sex marriage.