Kathleen A. Murphy was left a widow when her wife, from a marriage in Massachusetts, died of cancer in 2012.

Last year, Ms. Murphy, 62, applied to the Social Security Administration for spousal survivor’s benefits and the standard lump-sum death payment. But she was turned down because the couple lived in Texas — one of the 18 states, as of this week, that does not recognize same-sex marriages.

That decision, and the policy behind it to follow marriage laws in the state of residence to determine marital status, were challenged in federal court on Tuesday as unconstitutional forms of discrimination in a suit brought on Ms. Murphy’s behalf by Lambda Legal, a New York-based gay rights group.

“People’s constitutional rights shouldn’t be left behind because of where they live,” said Susan Sommer, the director of constitutional litigation for the group. She said the suit, filed in the United States District Court for the District of Columbia, was the first to directly challenge the Social Security residence-based policy on marriage and that thousands of couples could potentially be affected.