A state judge heard arguments on Wednesday on whether chimpanzees can be considered persons with some legal rights, as advocates seeking to free two chimps in captivity on Long Island asserted they were “autonomous beings” and compared their plight to that of human slaves.

“They are the kinds of beings who can remember the past and plan ahead for the future,” Steven M. Wise of the Nonhuman Rights Project told the court, “which is one of the reasons imprisoning a chimp is at least as bad and maybe worse than imprisoning a person.”

The unusual hearing in State Supreme Court in Manhattan concerned the fate of Hercules and Leo, two 8-year-old chimpanzees being studied by a researcher at Stony Brook University. The Nonhuman Rights Project has sued to have them released, trying to use the time-honored writ of habeas corpus, a cornerstone of American law that allows a person to challenge unlawful imprisonment.

But what is a person under the law? That was the focus of arguments before Justice Barbara Jaffe. Mr. Wise contended that chimpanzees are enough like humans that they should have a right to “bodily liberty,” even if other rights, like voting or freedom of religion, are beyond them.