Massachusetts, which became the first state to legalize gay marriage in 2003, also was the first state to challenge the law in 2009.