Media playback is unsupported on your device Media caption The result of the vote on gay marriage was read out to a packed House of Commons

David Cameron says he is proud the love of a same-sex couple will now "count the same" as that of a heterosexual couple, despite almost half his MPs voting against gay marriage.

MPs voted in favour of the Marriage (Same Sex Couples) Bill by 400 to 175, a majority of 225.

But 136 Tory MPs opposed the bill.

Mr Cameron paid tribute, during PM's questions, to those who had campaigned for "many years" and the "moving" speeches made by MPs during the debate.

MPs were given a free vote on the bill, meaning they were not ordered to vote a particular way by party whips.

Their decision to back the bill at second reading signifies that they approve of it in principle. The legislation will now receive more detailed parliamentary scrutiny.

'Lords opposition'

If it becomes law, the bill will enable same-sex couples, who are currently able to engage in civil partnerships, to get married in both civil and religious ceremonies - the latter only with the consent of religious institutions.

During Prime Minister's Questions, Mr Cameron said: "Last night's vote will be seen not just as making sure there is a proper element of equality, but also helping us to build a stronger and fairer society.

"I thought many of the speeches made last night were very moving, very emotional and I would pay tribute to all those people who have actually made this case, some of them for very many years, saying they want their love to count the same way that a man and a woman's love for each other counts.

"That is what we have opened now in this country and that is why I'm proud it is this government that has brought it forward."

Analysis It was a significant challenge to David Cameron's authority. Almost half of his own MPs failed to support him. There are warnings now of a lot of disaffected people within his party and predictions that that it could weaken his leadership. Tuesday's vote was a big moment but it has got further stages to pass in the parliamentary process. In the months and years ahead there is the possibility that this issue will fester with angry Tories, both in parliament and in associations across the country. There is another view though, that the prime minister will be delighted. He's had a very public confrontation with the notably more traditional part of his party over an issue that he believes is worth a big fight. He thinks marriage should be open to all. But he also sees it as a defining moment in his modernising mission. Crudely speaking, he hopes there will be votes in it come 2015.

Voting lists show that 136 Conservatives - almost half of the party's MPs - opposed the bill.

This figure included two cabinet ministers - Environment Secretary Owen Paterson and Welsh Secretary David Jones - eight junior ministers, and eight whips.

Of the remaining Conservative MPs, 127 were in favour, 35 did not vote, and five registered an abstention by voting both in favour and against.

Mr Paterson defended his decision to vote against the bill, saying his views were "not discriminatory at all".

"I have my idea and many agreed with me but many more didn't," he said. "I have a clear idea of what the definition of marriage is... I expressed that last night and this process continues through Parliament."

Among those who voted against, Conservative MP David Burrowes predicted that the legislation would receive substantial opposition when it arrived in the House of Lords.

However, he said the vote had shown that the party was in touch with the country: "The nation is divided, we have shown ourselves as a party to be divided."

Former Tory defence minister Sir Gerald Howarth said that the government had no mandate for such a "massive social and cultural change", which had not been mentioned in the 2010 Conservative manifesto.

Another Conservative MP opposed to same-sex marriages, Sir Roger Gale, says he hoped the the prime minister would make changes to the legislation.

Speaking on BBC Radio 4's Today programme, he said: "I think what we can do is ameliorate the worst of the effects of the proposed legislation."

He has suggested replacing register office marriages and civil partnerships with a new form of civil union to "strengthen the concept that marriage is a union between one man and one woman, to leave that to faith to implement".

Tory Mark Pritchard, who also voted against the bill, said he expected there would be "ongoing discussions over the progress of the bill", but denied that disagreement amongst Conservative MPs had "caused long lasting division" or that there had been "fundamental damage to the prime minister".

'Equality landmark'

Downing Street sought to play down the significance of the split in the Conservative Party, stressing that it had been a free vote.

The prime minister's spokesman said David Cameron "very much respected the opinion" of those who did not share his view.

Pressed over possible amendments to the legislation, the spokesman said Mr Cameron believed the safeguards in the bill were "the right and appropriate ones".

Mr Miliband, the leader of the opposition, welcomed the outcome of the Commons vote.

"This is a proud day and an important step forward in the fight for equality in Britain," he said.

"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."

Deputy Prime Minister and Liberal Democrat leader Nick Clegg said he believed people would look back at the vote and see it as "a landmark for equality in Britain".

He said: "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.

"The Liberal Democrats have long fought for equal marriage. It is party policy and I am proud that the Liberal Democrats are part of the coalition government that are making it happen."

Four of the 56 Liberal Democrat MPs opposed the legislation.

They included former coalition minister Sarah Teather who, in a statement, expressed concern that the definition of marriage was being changed, which could make family life more unstable.