Germany's parliament has voted overwhelmingly to legalize same-sex marriage, granting full marital rights to gay and lesbian couples and clearing the path for them to adopt children.

The bill was passed by 393 votes to 226, with many conservative MPs voting in favor of the measure. Chancellor Angela Merkel, who had opened the door to the snap vote earlier this week, voted against the change, sticking to her long-held beliefs.

“For me, marriage as it’s meant in the constitution is marriage between a man and a woman, and that’s why I voted against today," Merkel said after the vote. "It was a long, intense, and emotionally touching debate. That’s true for me personally as well. That’s why I hope that with this vote we were able to create not only mutual respect between the different positions, but also a bit more peace and unity in society.”



However, Merkel added that she supported adoption for same-sex couples.

The vote came just days after Merkel’s comments during a live event that she wanted to move the discussion about marriage equality toward a decision of conscience rather than imposing a party line, hinting, in effect, that her Christian Democratic Union (CDU) party would drop its opposition to a vote on marriage equality.

The move to allow a vote was already a significant shift for Merkel, who had previously said she had a “hard time” with the issue and had “difficulties” with giving gay and lesbian couples the right to adopt. Her party went into the 2013 election opposed to equal marriage and adoptions by same-sex couples over concerns for a child’s wellbeing. Just two years ago, the chancellor defined marriage as “coexistence between a man and a woman.”

During Monday’s event, Merkel also shared the story of a lesbian couple she met in her home constituency, who she said had contributed to shifting her views on marriage equality. The chancellor said she had been invited to dinner by the couple, who were caring for eight foster children, and saw that the children were well cared for. She described the encounter as a “life-changing experience.”

“If the youth welfare service entrusts a lesbian couple with eight foster children, then the state could no longer use child welfare as an argument against adoptions,” Merkel said.

The main opposition parties jumped on Merkel’s comments, forcing the issue onto the parliamentary agenda. The chancellor was left with no choice but to allow a free vote to take place without voting instructions for her MPs.

On Wednesday, the bill was officially approved for a vote by the parliament’s legal affairs committee, which had blocked the bill 30 times in the past.

Despite catching many by surprise, Merkel’s remarks on Monday did not come out of the blue. The Social Democrats (SPD), the Free Democratic Party, and the Greens, with whom Merkel will likely to have to negotiate to form a coalition after September’s election, had all said that marriage equality would be one of the conditions to forming a government.

Merkel knew this would be an issue during the election campaign, and the leadership of the CDU and sister party the Christian Social Union (CSU) had already been talking about their position, an official told BuzzFeed News. Merkel was also aware that there was a clear parliamentary majority for same-sex marriage, and that a vote would need to take place in the near future.

However, the same official said the chancellor didn’t intend for a vote to take place as early as this week, and would have preferred the issue to be preceded by a more substantive parliamentary debate.

In an interview with the German publication WirtschaftsWoche on Wednesday, Merkel called the disagreement with the SPD “sad” and “completely unnecessary.”

For its part, the SPD had little sympathy for the CDU’s position. The party’s chairman Thomas Oppermann told broadcaster ZDF ahead of the vote that marriage equality wasn’t an election tactic: “For us, marriage for all is a question of conviction.”

A poll released ahead of the vote found that three-quarters of Germans, including the vast majority of CDU/CSU supporters (73%), backed same-sex marriage, while 72% had welcomed Merkel’s decision to allow a free vote among her party’s MPs.

Germany will join a dozen other European countries in having same-sex marriage: Norway, Sweden, Denmark, Finland, Iceland, the Netherlands, Belgium, Spain, Portugal, Luxembourg, France, the Republic of Ireland, and the UK (except Northern Ireland and Jersey). The change will take effect later this year after the bill is signed into law by the country's president.