Why is the state allowed to define sex for the purpose of assigning rights?

This question has been simmering in the back of my mind for a long time.

As a result of covering stories related to LGBT rights, and particularly, debates over hate crimes (see the “small murders” section) and same-sex marriage, it occurred to me that laws that use sex as a criteria for assigning marriage rights require the state to define a person’s sex. I am using the word sex here as a matter of biology, as opposed to gender, which is a matter of cultural performance. However, not everyone has a clear sexual identity, especially at birth. Given the variation in human biological sex that exists in nature, it’s hard to see how the state can define who is a same-sex or opposite sex couple without violating the equal protection clause of the constitution, which requires that laws be applied equally to all.

Whose rights are affected by laws assigning marriage rights on the basis of sex? Transsexual people who have been medically diagnosed with gender identity disorder have the outward appearance of being one sex, but have brains wired for the opposite sex. Transsexual people may have same-sex or opposite sex orientations. There have been legal cases in which the marriages of transsexuals to people they view as their opposite-sex partners have been invalidated by judges who insisted that biological sex is fixed at birth, is revealed by external genitalia, and can’t be changed.

However, intersex people may be born with ambiguous genitalia, or may present as one sex at birth and find at puberty that they have the sexual anatomy of the opposite sex. Parents and doctors guess the gender with which the newborn is most likely to identify, and they don’t always get it right. If you have someone who appears to be female, or is classified as female at birth, and who is ultimately determined to be male, what gives the state the right to decide whom that person is allowed to marry? Should that not be a private decision?

I don’t think that taking the legal definition of sex out of the hands of the state would invalidate sex discrimination laws, or keep private organizations from having membership or hiring criteria based on sex. For example, the Catholic church can continue to insist that all priests be male based on they perceive a male to be, because they are a private organization. An employee can still sue for sex discrimination based on their self-identification as a member of a particular sex, their employer’s identification of them as a member of a particular sex. All I’m questioning is whether the state has the right to determine who is of a particular sex.

In my mind, none of this is related to moral beliefs anyone might have about homosexuality, transsexualism, or gay marriage. I’m simply asking whether this is something that belongs in the state’s purview?

I’m not a lawyer, so there is a very good chance I’m missing something. Any thoughts?