For the first five years of his daughter Amanda’s life, Ping N., a restaurant manager in Manhattan, lived with his little girl and her mother. He tucked her into bed at night and enjoyed spoiling her with her favorite snacks, like fish balls, egg tarts and ramen noodles.

This story was produced in partnership with The New York Times

But when child welfare officials found that Amanda’s mother had inflicted excessive corporal punishment on her in 2013, they removed the girl from the home. Even though court records show that Ping had never committed abuse and was not present when it took place, a judge later decided that he would lose his daughter, too. Ping could not have custody or any say in her life anymore.

The reason was a quirk of New York State law: He and Amanda’s mother were not married when she was born, making him less of a father in the eyes of the courts.

Lawyers for Ping, an immigrant from China whose surname is being withheld to protect the identity of his children, are now appealing that decision in what they hope will be a test case that changes how the decades-old law treats unwed fathers.

In New York and 11 other states, if a mother is accused of abuse or neglect but the father is not, and he is not married to her, he must prove that he is a parent in his own right—otherwise he will not have a say in whether the child is put up for adoption. In most of those states, including New York, proof means paying child support—not to the mother but to the government agency that has taken the child.

“This is just blatant discrimination based on stale gender stereotypes—that the only way to be a father is to have a wedding ceremony or else to be a kind of rote financial provider,” said Martin Guggenheim, a law professor at New York University who studies family law and children’s rights.

Defenders of the New York law, which dates to 1980, say it helps children who have been languishing in foster care to get a permanent home sooner by preventing unmarried fathers who do not support their children from using the courts to delay or stop an adoption.

If those fathers had full rights, “we would have to prove by clear and convincing evidence that he abandoned the child … which can take years,” said Ira L. Eras, a New York lawyer who has mostly represented foster care agencies for three decades.

A Family Court judge in Manhattan ended Ping’s parental rights last year, paving the way for Amanda’s adoption by another family. The judge cited Ping’s status as an unwed father at the time of his daughter’s birth and his failure to pay child support to Catholic Guardian Services, the foster care agency that the city’s child welfare arm, the Administration for Children’s Services, had hired to take custody of the girl.

Ping’s appeal, which was submitted in February and will be argued this fall by lawyers with the Family Defense Clinic at New York University School of Law, contended that he was financially supporting his daughter by giving her clothes, toys, food, gift cards and money, as well as by paying for outings and meals they had together. Ping said he was never told that he also owed child support to the government and had never received a bill.

His lawyers added that there was no apparent way for fathers to pay child support to New York foster care agencies, a claim echoed by other lawyers in similar cases.

A spokeswoman for the Administration for Children’s Services, Chanel Caraway, and the executive director of Catholic Guardian Services, Craig Longley, both said they could not comment on a specific case. Caraway also declined to comment on whether the agency had ever tried to get fathers to pay child support in these situations.

The state does not track how often the law is given as the reason for ending a father’s parental rights. But a review of Family Court decisions and interviews with foster care lawyers suggests it is routinely cited in those cases.

Last week, David Dunbar, a 43-year-old overnight grocery store manager from the South Bronx, narrowly missed becoming one of them.

After the mother of Dunbar’s daughter developed severe mental illness in 2014, the children’s services agency deemed her to be an unfit parent and placed the girl, Destiny, then 10, in foster care. In order for her to be adopted, the agency had to show that Dunbar was also not a fit parent.

Although court records show that Dunbar consistently visited Destiny, took parenting classes and passed drug tests, the foster care agency, St. Dominic’s Family Services, argued that his rights should be ended in part because he failed to communicate regularly with officials about his plans for his daughter.

As the years went on, the agency began citing the state’s decades-old law as an alternate reason for ending Dunbar’s rights, court records show. But at a hearing in Manhattan on Sept. 18, the agency dropped its petition, largely because Destiny, now 16, had repeatedly stated to the court that she wanted to be with her father.

“I loved my daughter’s mother,” Dunbar said. “I wish I could’ve married her. I wish we could have lived a wonderful life together. But we didn’t. That doesn’t mean I’m not a dad.”

Diane Aquino, the chief operating officer of St. Dominic’s Family Services, said that she could not comment on an individual case but that the agency would not try to end a father’s rights if he were “actively planning for his child.”

“Five years in foster care indicates a father who is only intermittently planning,” Aquino said.

A half-century ago, unwed fathers had even fewer rights. But a landmark Supreme Court decision in 1972 redefined fatherhood, to an extent.

In that case, the justices found that a state could not deny an unwed father his parental rights without demonstrating that he was unfit. Over the next decade, legislators in New York and at least nine other states decided that the fitness of these unmarried fathers would be judged by whether they paid child support and maintained some relationship with the child.

When those laws were passed, many policymakers had a particular scenario in mind: a single mother who wanted to give up her child for adoption. Their goal was to prevent an absentee father from thwarting the mother’s decision without having paid child support.

But they did not take into account adoptions that occurred after a government agency had taken a child from a mother because of abuse or neglect. In order to satisfy the law, the unwed father would technically have to send payments to the government.

In New York, lawyers for fathers said that making payments to foster care agencies was not even possible. The agencies do not try to collect the money, they said, and fathers do not know where or to whom to send it.

“I’ve tried to imagine ways of doing it—having my clients get child support orders against themselves, which they can then pay, or offer to pay the agency in cash every time they can, just so it’s in the record that they tried,” said Yusuf El Ashmawy, a lawyer who represents Dunbar and other fathers. “It’s mind-bending.”

Since its passage nearly four decades ago, New York’s law has not been updated, even as the culture and the courts have embraced more expansive views of what makes a family.

The state’s highest court struck down an earlier provision requiring unwed fathers to be living with their child’s mother in order to have a say in an adoption, but it has not directly ruled on other aspects of the statute.

Ping’s lawyers hope his argument will sway the court.

His daughter Amanda, now 11, was adopted by a white family with whom she has bonded. She lost her ability to communicate with Ping in Mandarin; he does not speak English. Ping eventually married Amanda's mother, and they had a son, Owen, now 6. Ping’s wife has since died, and he is raising his son on his own.