New York City is to hold a lottery to determine which gay couples can be the first to tie the knot when a gay marriage law comes into power on Sunday.

Mayor Michael Bloomberg said that demand to wed on the first day gay marriage is legal far outstrips supply and 764 couples, including straight couples, will be permitted to wed on the day.

Register offices around the city will open this Sunday and Mr Bloomberg said the lottery was designed to avoid long queues and disappointment.

He said: “The last thing we want is for couples to wait on line for hours and hours, only to walk away upset on what was supposed to be the happiest day of their lives.

“The fairest way to determine who gets the chance to wed on Sunday and ensure everyone can properly plan for their own big day is through an even-handed lottery system.”

He added: “Nobody puts on big events like New York and we will be ready on Sunday for what will no doubt be an historic and unforgettable moment.”

Usually couples must wait 24 hours to wed after applying for a marriage licence. However, more than 60 judges have volunteered to hold on-the-spot hearings to waive the waiting period.

In the last fortnight, 1,728 gay couples in New York City have applied to marry.

The state legalised gay marriage last month,

Five other states – Massachusetts, Connecticut, Iowa, New Hampshire and Vermont – and the District of Columbia – currently allow gay couples to marry.