It does so for federal tax purposes, yes. It does not prohibit a state from having gay marriage, though.
`In determining the meaning of any Act of Congress, or of any ruling, regulation, or interpretation of the various administrative bureaus and agencies of the United States, the word
`marriage' means only a legal union between one man and one woman as husband and wife, and the word `spouse' refers only to a person of the opposite sex who is a husband or a wife.'
I don't see how Massachusetts (or any other state for the matter) that recognizes gay marriage wouldn't be in violation of the law.