In an unprecedented decision, an Argentine court has ruled that the Sumatran orangutan 'Sandra', who has spent 20 years at the zoo in Argentina's capital Buenos Aires, should be recognized as a person with a right to freedom.

The ruling, signed by the judges unanimously, would see Sandra freed from captivity and transferred to a nature sanctuary in Brazil after a court recognized the primate as a "non-human person" which has some basic human rights. The Buenos Aires zoo has 10 working days to seek an appeal.

The "habeas corpus" ruling in favor of the orangutan was requested last November by the Association of Professional Lawyers for Animal Rights (AFADA) alleging that Sandra suffered "unjustified confinement of an animal with proven cognitive ability."

Lawyers argued that just as a person, the ape is capable of maintaining emotional ties and has the ability to reason, while feeling frustrated with her confinement. Furthermore, the legal team claimed that the 29-year old orangutan can make decisions, has self-awareness and perception of time. And therefore, all things considered, Sandra's presence at the Zoo constituted illegal deprivation of liberty.

Habeas corpus is a fundamental legal term in human rights, dating back to the early fourteenth century during the reign of Edward I in England. At that time courts began requiring the monarchy to report the reasons behind restricted freedom of a subject.

Orangutan in Argentina zoo set to be granted freedom from "unlawful imprisonment" http://t.co/8GsoplZIncpic.twitter.com/PvMhydqFP7 — Lyndsay Farlow (@LyndsayFarlow) December 22, 2014

"This opens the way not only for other Great Apes, but also for other sentient beings which are unfairly and arbitrarily deprived of their liberty in zoos, circuses, water parks and scientific laboratories," the daily La Nacion newspaper quoted AFADA lawyer Paul Buompadre as saying.

Sandra who was born in 1986 in the German zoo of Rostock, arrived in Buenos Aires in September 1994, where she’s spent 20 years behind bars. The World Wildlife Foundation (WWF) claims Sumatran orangutan to be the most endangered of the orangutan species. Found only in the northern and western provinces of Sumatra, Indonesia, the species is fast losing its natural habitat to agriculture and human settlements.

READ MORE: Apeus corpus? Chimps not human, says New York court

Sandra's case is not the first in which "habeas corpus" was invoked to secure the release of wild animals in human captivity. However, in the US the two recent cases failed. A New York court, earlier this month has ruled that Tommy chimpanzee was not legally a person and is therefore not entitled to human rights. And in 2011, a lawsuit against SeaWorld to free five wild-captured orca whales was dismissed by the San Diego court.