The first gay marriages in England and Wales are set to take place in 2014 after the legislation passed through parliament's upper chamber the House of Lords on Monday.
Jubilant gay rights activists cheered outside parliament as the bill cleared unopposed, while gay lawmaker Lord Waheed Ali told colleagues in an emotional speech: "My life and many others will be better today than it was yesterday."
The government-backed legislation now passes back to the lower House of Commons for final debates on Tuesday, but they are expected to be little more than a formality.
A spokesman for the culture ministry, which is overseeing the legislation, said the bill would probably receive official assent from Queen Elizabeth II, the head of state, on Wednesday or Thursday.
"But we are looking at seeing the first gay weddings in the middle of 2014 because there are various issues to sort out, such as its impact on pensions," the spokesman told AFP.
Supporters of the bill in the House of Lords wore pink carnations, while gay marriage activists danced outside the Houses of Parliament.
Gay rights activists have vowed to press on for equal marriage in Britain's other constituent nations, Scotland and Northern Ireland.
Deputy Prime Minister Nick Clegg said the new law would ensure that lesbian, gay, bisexual and transgender people felt "recognised and valued, not excluded".
The legislation represents "the kind of open, modern, tolerant and diverse society we want Britain to be in the 21st century", he added.
But opponents of gay marriage warned that the legislation would "come back to bite" Prime Minister David Cameron.
The Coalition for Marriage campaign group said it would mobilise a 700,000-strong support base ahead of next year's European elections and the general election in 2015.
The bill survived despite opposition from dozens of members of Cameron's own Conservative party, and an attempt to kill it off with a "wrecking amendment" in the Lords last month failed.
Veteran gay rights campaigner Peter Tatchell said it was "a defeat for discrimination and a victory for love and marriage".
"It is of huge symbolic importance, signalling that same-sex love has social recognition, acceptance and parity," he said.
Gay couples in Britain have had the right to enter into a civil partnership since 2005, giving them identical rights and responsibilities to straight couples in a civil marriage.
But campaigners point to some differences such as international recognition, which applies to marriage but not partnerships.
The new law will ban the established Churches of England and Wales -- which are opposed to gay marriage -- from conducting ceremonies.
Other religious institutions will be able to "opt in" if they wish.
Scotland and Northern Ireland have their own laws on the matter.
The Scottish government published its own same-sex marriage bill last month, but Northern Ireland's assembly voted to block a similar measure.