France's lower house of parliament has backed same-sex marriage in a vote, paving the way for it to enter law.
In recent weeks street marches have rallied hundreds of thousands of demonstrators both for and against it.
The move is France's most important social reform since the abolition of the death penalty in 1981.
It is opposed by social conservatives in the majority Catholic country, together with many French Muslims and evangelical Christians.
Assuming it is passed by the Senate upper house in a 2 April vote, France will join 11 other countries including Belgium, Portugal, the Netherlands, Spain, Sweden, Norway and South Africa where same-sex marriage is legal.
A further nine US states and Washington DC allow same-sex marriage, while British lawmakers earlier this month backed it in an initial vote.
"We've waged a great and noble battle," Justice Minister Christiane Taubira, the bill's main promoter, told journalists ahead of the 329 vs 229 vote in favour of the bill.
President Francois Hollande's Socialists hold a majority in the National Assembly, which allowed them to overcome attempts by opponents to delay proceedings with around 5,000 amendments that took over 100 hours of acrimonious debate.
The Socialists and their allies together hold a majority in the Senate.
Known in France as "marriage for all", the gay marriage bill has proven to be the most divisive social initiative undertaken by Mr Hollande's government in his nine months in power.
On 13 January, a survey by pollster CSA showed it had split the population roughly in two, with a slim majority of 51% in favour and 43% opposed.
Legislators dropped a plan to also allow lesbians access to artificial insemination that proved highly contentious among voters.
A separate bill covering that is due for debate later this year.
Two thirds of French people describe their religion as Roman Catholic, though church attendance has dwindled since the 1970s. France is home to large Muslim and Jewish populations, which number about 5 million and 500,000 respectively.
The centre-right UMP party, freshly emerged from a leadership crisis, rallied its troops for marathon filibustering sessions which spilled over into evenings and weekends.