The courts have asked this question in a recent case in New Jersey. Here's what happened:
A New Jersey judge has ruled that a gestational surrogate who gave birth to twin girls is their legal mother, even though she is not genetically related to them.
The ruling gives the woman, who carried the babies in an arrangement with her brother and his male spouse, the right to seek primary custody of the children at a trial in the spring.
This reminds me of another case from 2007:
A New York man who said he donated sperm to a female co-worker as a friendly gesture and sent presents and cards to the child over the years likely will owe child support for the college-bound teenager, according to a judge's ruling.
This is a trend. (here is another case, and here is the first one I recall seeing, a case from Sweeden in 2005). Our friends on the Left like to say that marriage is a social construct. Yet our Courts keep putting biology (sometimes as raw genetics, and sometimes as the fact of carrying a baby to term) back in.
A further, and related point. I have wondered before whether, given the rise of out-of-wedlock births, our courts will re-create something like common law marriage. If they may impose obligations on, and discover rights for, people who agreed not to be considered parents, so much more would it follow logically for the law to impose obligations on parents who were a couple when the baby was conceived.