Two chimpanzees sit on sand in Kenya in this undated photo.

In a historic moment for animal rights, two chimpanzees, Hercules and Leo, were effectively recognized by a New York court as legal persons Monday.

Hercules and Leo, who are currently used for biomedical experiments at Stony Brook University on Long Island, were granted a hearing on their habeas corpus petition by Manhattan Supreme Court Justice Barbara Jaffe.

Habeas corpus is a legal petition that detainees use to seek relief from unlawful imprisonment, and by granting habeas corpus to chimps, Jaffe endorsed the idea that they deserve the rights of a human being with respect to being confined indefinitely and in less than humane conditions.

Advocates argue great apes are highly intelligent and self-aware beings with complex emotional lives that deserve basic rights, including the right to be free of inhumane treatment.

A similar tack was taken by lawyers in Argentina last year when a court ruled that an orangutan kept at private zoo in Buenos Aires for the past 20 years should have some basic legal rights.

According to Nonhuman Rights Project (NhRP), which filed the habeas corpus petition in March in an effort to move the primates to a sanctuary in Florida, Jaffe's ruling is a first for animal rights.

Stony Brook University must now provide the court with a legally sufficient reason for keeping Leo and Hercules in captivity or the chimps will be set free. The court has scheduled the hearing for May 6, according to NhRP.

Caroline Forell, a University of Oregon professor who teaches animal law, told BuzzFeed News that the court's decision to consider granting the chimps habeas corpus is "a pretty big deal."

But she noted that it is a two-step process, and that the upcoming hearing would be an important opportunity for evidence to be presented in court.

The outcome could have a huge impact on Leo and Hercules, who have been confined at Stony Brook University for locomotion research, but whose specific conditions for the past few years are unknown, The Dodo reported. It is not clear if the chimps are even allowed to interact with one another.

NhRP hopes Leo and Hercules can be moved to Save the Chimps in Fort Pierce, Florida, where hundreds of other chimpanzees live in a habitat that is designed to replicate Africa.

Forell told BuzzFeed News she thinks a trial court would likely not make such a unprecedented ruling. Instead, she said ​the court will likely ​not​ grant ​the habeas ​corpus petition​ and allow advocates to appeal the ruling up to an appellate court.

A court decision could also impact hundreds of other apes who are confined in labs and elsewhere.

Similar cases have been filed for two other chimpanzees — Tommy, who lives in a cage on a used trailer lot in Gloversville, New York, and Kiko, who is held on private property in Niagara Falls — and decisions are still pending in New York's Court of Appeals.