The case is being closely watched across the country. If the Supreme Judicial Court strikes down a 1913 law, same-sex couples from across the country could wed in Massachusetts and demand marriage rights at home.
Eight gay couples from surrounding states, all of whom were denied marriage licenses in Massachusetts, are challenging the law. It forbids nonresidents from marrying in the state if their union would not be recognized in their home state.
Massachusetts last year became the first state to allow same-sex marriage. Forty-one others have passed laws or constitutional amendments banning it.
Michele Granda, a gay-rights lawyer for the couples, argued Thursday that the 1913 law "sat on the shelf" unused for decades until it was "dusted off" by the governor.
Granda said the high court, in its historic ruling legalizing gay marriage, found that under the Massachusetts Constitution, same-sex couples had the same right to marry as heterosexual couples.
"Nothing in (that ruling) says that our officials can discriminate simply because officials in other states discriminate," Granda told the six-judge panel.
Attorneys for the state argued that the law is being enforced in an evenhanded way.
Assistant Attorney General Peter Sacks said Massachusetts risks a "backlash" if it flouts the laws of others states by marrying gay couples from states that prohibit it.
"We've got respect for other states' laws," he said.
The high court is expected to rule in the next few months.
The eight couples who sued are from Connecticut, Rhode Island, New Hampshire, Vermont, Maine and New York.
They include Sandi and Bobbi Cote-Whitacre of Essex Junction, Vermont, who have a recognized civil union in their home state but want to marry.
"The civil union gave us state benefits, but we GREw up believing that you find someone you want to spend the rest of your life with and you get married," Sandi Cote-Whitacre said.
"In reality, after 38 years, I'm her wife and she's mine,"he added. "We want the document."
After same-sex marriage became legal in May 2004, Romney ordered city and town clerks to enforce the 1913 law and wrote to every other governor in the nation that out-of-state gay couples would not be allowed to marry in Massachusetts. A few communities initially defied the governor but eventually complied.