President Francois Hollande into backing down from signing the bill.
In its second and final reading, the lower house of parliament, the National Assembly, voted 331 to 225 to adopt the bill allowing homosexual marriages and adoptions by gay couples.
Socialist Justice Minister Christiane Taubira hailed the approval of the bill as a "historic" moment.
"It grants new rights, stands firmly against discrimination (and) testifies to our country's respect for the institution of marriage," she said in a statement shortly after the vote.
But the tension remained high inside parliament as well as on the streets. Ushers ejected two protesters from the parliamentary chamber as they unfurled a protest banner.
Soon after the law was voted through, lawmakers from right-wing parties filed a legal challenge with the constitutional council.
Senators from the main opposition UMP and other right-wing parties said "the definition of marriage, a fundamental principle, cannot be modified by a simple law". "Provisions allowing adoption by gay couples violate "fundamental principles" of France, including "the principle of human dignity and equality", they argued.
Thousands of opponents of the law also refused to give up, demonstrating near to the National Assembly on Tuesday evening.
"We are going to show them that this is not over," said the campaigner known as Frigide Barjot, leader of the "Manif pour tous" (Demo for All) group that has battled the bill. She called on Hollande to hold a referendum on the issue. Another mass protest is already planned for May 26.
The Catholic Bishops' Conference of France expressed its disappointment at the law and Bishop Bernard Podvin told AFP of his "deep sadness". "Democracy has spoken," he said. "But such a controversial law will not produce social cohesion."
But for Nicolas Gougain, a spokesman for Inter-LGBT, France's leading gay rights group, the law was a victory for equality and democracy. "This law takes no rights away from anyone, it only grants rights to others. This is liberation after years of fighting for equality."
In Paris, late Tuesday, police again clashed with violent protesters among those opposing the law, as they had done during a series of protests in the capital the week before.
One officer received a head injury as protesters threw firecrackers, bottles and stones at police, who responded with tear gas and made 12 arrests.
The constitutional council now has a month to make a ruling, but the government expressed confidence that the constitutional challenge would be dismissed.
Hundreds of thousands have taken to the streets in a series of protests against the bill, surprising many in a country that, being predominantly Catholic, is known for its secular traditions.
Hollande could scarcely have anticipated the scale of the opposition he would face over a reform that initially seemed to enjoy solid majority backing among French voters.
But recent polls have suggested a campaign in which the Roman Catholic Church initially played the leading role has shifted opinion to the extent that the electorate is now fairly evenly split on both gay marriage and adoption.
Opponents of gay marriage are still hoping they can build up enough pressure to persuade Hollande, who has been steadfast in supporting the bill, to step back from signing it.
Hollande's partner, Valerie Trierweiler, has revealed that the president will be attending the marriages of gay friends once the legislation is on the statute books.
In a tweet after the vote, Trierweiler hailed Tuesday as a "historic day", using the hashtag "#equalityforall".
France's INSEE statistics agency says about 200,000 people declared themselves as living as same-sex couples in a 2011 study.
If Hollande signs the law, France will join eight other European countries - the Netherlands, Belgium, Spain, Norway, Sweden, Portugal, Iceland and Denmark - in legalising same-sex marriages.