The office of Germany's president said Friday that he had signed a bill into law that legalizes same-sex marriage.

President Frank-Walter Steinmeier signed the legislation on Thursday, his office said, paving the way for the legislation to take effect as early as October 1.

The bill, which makes Germany the 14th European country to approve same-sex marriage, passed with a 393 to 226 vote, with four abstentions, during the German parliament's last session before Germans head to the polls in September.

The opportunity to move on the issue appeared when Chancellor Angela Merkel signaled that she would support a free vote on the issue among her party members.

Merkel was under increasing pressure to act on the issue from potential coalition partners that may emerge from September's upcoming election. Merkel herself, however, voted against the bill.

(Related: Angela Merkel reiterates opposition to gay marriage.)

According to a poll released in April and commissioned by German Sunday newspaper Bild am Sonntag, 75 percent of Germans support same sex marriage, while 20 percent remain opposed. A survey by the Federal Anti-Discrimination Bureau released in January found higher support, with 83 percent of respondents saying marriage between two people of the same sex should be allowed.

Since 2001, Germany has recognized gay and lesbian couples with civil partnerships. The union, however, lacks some of the benefits enjoyed by married couples, such as being able to adopt children together.