France has become the 14th country to approve a law allowing gay marriage.
The bill, which also legalises adoption by same-sex couples, was passed by 321 votes to 225 in the French parliament.
The decision follows a divisive public debate with some of the biggest protests seen in France in recent years.
More protests by supporters and opponents are expected and thousands of police have been deployed in central Paris in preparation.
Although previous rallies have been overwhelmingly peaceful, some clashes on the fringes of opponents’ protests have been blamed on far-right elements.
Opinion polls suggest a small majority of French people favour gay marriage, but opinion on adoption by same-sex couples is even more divided.
Socialist President Francois Hollande made the law his flagship social reform.
He is expected to add his signature to the bill once it has cleared any challenge in the constitutional council.
Opponents of the measure, including the opposition UMP party, will try to convince the council that marriage is a constitutional issue.
However, analysts say that the council is unlikely to block the new law.
The first weddings could take place in June, according to Justice Minister Christiane Taubira.
“We believe that the first weddings will be beautiful and that they’ll bring a breeze of joy, and that those who are opposed to them today will surely be confounded when they are overcome with the happiness of the newlyweds and the families,” she told parliament.
Some argue this is the most important social reform in France since the death penalty was banned in 1981, says the BBC’s Christian Fraser in Paris.
France is now the 14th country to legalise gay marriage after New Zealand last week.
It is also the ninth country in Europe to allow same-sex marriage after legalisation in the traditionally liberal Netherlands and Scandinavia, but also in strongly Catholic Portugal and Spain. Legislation is also moving through the UK Parliament.
But the measure has aroused stronger than expected opposition in France – a country where the Catholic Church was thought to have lost much of its influence over the public.
In January, a protest in Paris against the bill attracted some 340,000 people according to police – one of the biggest public demonstrations in France in decades. Organisers put the figure at 800,000.
Since then both sides have held regular street protests.
The opponents, backed by the Catholic Church and conservative opposition, say France already has civil partnerships for homosexual couples, and extending rights to marriage undermines an essential building block of society.