New York City, whose top elected officials strongly supported the legalization of same-sex marriage, will take the unusual step of opening city offices on a Sunday, July 24, so gay couples can marry on the day the law takes effect.

The city clerk’s offices in all five boroughs will open that day, and judges will be on hand to officiate at the weddings after couples receive marriage licenses.

The decision by city officials to expedite same-sex weddings comes as city and town clerks across the state are grappling with the fact that the law goes into effect on a day when municipal offices are usually closed. Officials in some cities and towns say they are expecting a surge in marriage applications from same-sex couples.

The announcement came a day after the city began allowing gay couples to apply online for marriage licenses, though they cannot be issued until July 24 — 30 days after Gov. Andrew M. Cuomo signed the same-sex-marriage legislation following its approval by the Legislature.