A British photographer won a two-year-long legal battle against animal rights group People for Ethical Treatment of Animals in the United States over a “monkey selfie”, BBC reported on Tuesday.

A macaque monkey had picked up a camera owned by David Slater, and had inadvertently taken several images of itself in an Indonesian jungle in 2011. Peta had filed a petition on the “monkey’s behalf’’, claiming copyright protection for the animal.

However, the judges ruled that the monkey was not entitled to copyright protection. While the court rejected Peta’s argument that the monkey should benefit from the proceeds of the photograph, Slater said he would donate 25% of any future earnings from the photograph to registered charitable organisations.

Peta had claimed that the monkey in the image was a female named Naruto, but Slater had said it was a different male macaque. The case was listed as Naruto v David Slater.

In a joint statement, Peta and Slater said the case had raised the debate over legal rights for animals. “Peta and David Slater agree that this case raises important, cutting-edge issues about expanding legal rights for non-human animals, a goal that they both support, and they will continue their respective work to achieve this goal.”