Supporters of same-sex marriage have hailed MPs' vote to legalise gay weddings in the UK.

David Cameron said the vote has been "an important step forward" after 400 MPs voted in favour of the motion and 175 against. The MPs were given a free hand as 136 Tory MPs voted against gay marriage.

The vote grants same-sex marriages the same legitimacy as heterosexual unions. Same-sex partners will be allowed to engage in both civil and religious ceremonial weddings provided they have the consent of religious institutions.

"As a boy I never thought this moment would happen in my lifetime. It's really quite emotional," 44-year-old Greg Leonard told the Guardian.

Many supporters were seen outside parliament while the MPs were casting their vote. Opposition leader Ed Miliband described it as a "proud day".

"The overwhelming majority of Labour MPs supported this change to make sure marriage reflects the value we place on long-term, loving relationships - whoever you love," said Miliband.

Deputy Prime Minister Nick Clegg has also hailed the decision, saying he is "proud" to be part of the coalition which is making the gay marriage approval happen.

"No matter who you are and who you love, we are all equal. Marriage is about love and commitment, and it should no longer be denied to people just because they are gay," said the Lib Dem leader.

"This bill is a validation of love between people of the same sex, denying us the right to get married is an insult to those many lesbian and gay couples in long term relationships who simply want the same rights as everyone else," said the gay rights campaigner, Peter Tatchell, who added that the bill carries "huge symbolic importance".

However Tory MPs opposed to gay marriage accused Cameron of dividing the Conservatives with the vote. Nearly half of the party's MPs voted against the bill and their numbers include two cabinet members, environment secretary Owen Paterson and Welsh secretary David Jones.

"The nation is divided, we have shown ourselves as a party to be divided," said Conservative MP David Burrowes.