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.
The bill must still be signed by President Francois Hollande and is to face a challenge in France's constitutional council.
Justice Minister Christiane Taubira immediately hailed the adoption of the bill as a "historic" moment in French history.
"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.
"This law brightens the horizons of many of our citizens who were deprived of these rights," she said.
But shortly after the vote, lawmakers from right-wing parties said they had already filed a legal challenge with the constitutional council.
It will have a month to make a ruling and opponents are hoping that in the meantime they can build up enough pressure to force Hollande, who has been steadfast in supporting the bill, to back down from signing it.
Former president Jacques Chirac shelved an unpopular employment law that had been passed by parliament in 2006, but Hollande is seen as unlikely to follow that precedent.
The government is also confident that the constitutional challenge will be dismissed.
"We have ensured that there is no legal weakness," Family Minister Dominique Bertinotti said. "The constitutional council is sovereign but the government is serene. We're confident."
Hundreds of thousands have taken to the streets in a series of protests against the bill, surprising many in a country that is predominantly Catholic but known for its liberal views.
The opposition turned increasingly nasty as the final vote approached.
Some politicians received personal threats, a handful of demonstrations ended in violence amid claims of infiltration by extreme-right activists, and there was even a scuffle in parliament as the debate concluded in the small hours of Friday.
The Socialist speaker of the lower house, Claude Bartolone, on Monday received an envelope containing ammunition powder and a threatening letter demanding he delay Tuesday's vote.
The tensions have also been linked to a spike in hate crimes against the gay community that have included attacks on bars and two serious assaults in Paris, prompting the police to take preventive measures in case of a further backlash.
The opposition UMP has succeeded in making gay marriage a focus of broader discontent with the government over the parlous state of the economy and a recent scandal in which Hollande's ex-budget minister was charged with tax fraud after admitting to having an undeclared foreign bank account.
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 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.
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.
New Zealand on April 17 became the first Asia-Pacific country to legalise same-sex marriages after a parliamentary vote overwhelmingly backed the move.