The draft law, which proposes legalising same-sex marriage in England and Wales in 2014, was carried by 400 votes to 175 votes in the House of Commons.
The legislation is several stages away from becoming law, but has already exposed rifts within Mr Cameron's party at a time when he is facing growing talk of a possible leadership challenge.
But with the majority of Liberal Democrat and Labour MPs supporting the bill, it passed easily.
The new law would also allow civil partners to convert their partnerships into marriages.
In a late intervention just two hours before lawmakers voted, Mr Cameron made a televised statement to say the move was about "making our society stronger".
"I think it's right that gay people should be able to get married too," he said.
"This is yes about equality, but it's also about making our society stronger.
"I know there are strong views on both sides of the argument. I respect that. But I think this is an important step forward for our country."
Gay couples in Britain have had the right to enter into civil partnerships and adopt children since 2005.
The new law does not force the Anglican and Catholic churches - who strongly oppose the move - to conduct gay marriages, but critics say gay people may launch legal challenges.
Behind in the polls, analysts believe Mr Cameron is trying to perform a balancing act to reconcile his desire to show his party is progressive with the views of many of those inside it uncomfortable with such reform.
Amid growing talk of a possible leadership challenge against him, many Conservative MPs say they feel Mr Cameron is not a real Conservative and is sacrificing what were once core party values on the altar of populism.
If the legislation's passage is just as smooth in the House of Lords, Britain will become the 12th country to legalise same-sex marriage.