O'Malley, Senate President Thomas V. Mike Miller Jr. (D-Calvert) and House Speaker Michael E. Busch (D-Anne Arundel) sat at a table at the bottom of a marble staircase leading to the second floor of the State House and O'Malley's office in Annapolis.
Behind O'Malley was Lt. Gov. Anthony G. Brown and First Lady Katie O'Malley, who also had advocated forcefully for the bill.
Gay-rights leaders and clergy members lined the ascending staircase.
Hundreds of onlookers, lawmakers and 15 television cameras crowded in the hallway.
Both houses of Maryland's General Assembly narrowly approved gay marriage last month, ending a year-long odyssey for the legislation that sidelined many other issues in state government while it occupied center stage.