(Reuters) - A novel U.S. legal battle over who owned a famous smiling “selfie” taken by a critically endangered monkey six years ago - the animal who snapped the picture or the nature photographer who owned the camera - has been settled out of court.

Attorneys for Naruto, a rare crested macaque, and for David Slater, a British photographer, announced that Slater has agreed to donate 25 percent of the photograph’s future revenue to charitable groups that protect Naruto and other members of his species in Indonesia.

The two sides asked the 9th U.S. Circuit Court of Appeals in San Francisco, which heard oral arguments in July after a lower court denied Naruto’s claim, to dismiss the case.

The dispute stemmed from an image that Naruto, who lives on a nature reserve, snapped using a camera that Slater left mounted and unattended during a 2011 trip. The photograph of his grinning visage, which Slater published in a wildlife book, went viral.

People for the Ethical Treatment of Animals (PETA) sued on Naruto’s behalf, arguing the monkey was the legal owner of all photos he took. But a federal judge in San Francisco ruled in January 2016 that copyright law does not apply to 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,” the two sides said in a joint statement.

PETA has posted the photo online at bit.ly/2h28MMC.

The group’s general counsel, Jeff Kerr, said the organization was happy the deal would provide support for crested macaques, whose existence has been threatened by poaching.

“PETA’s groundbreaking case sparked a massive international discussion about the need to extend fundamental rights to animals for their own sake, not in relation to how they can be exploited by humans,” he said.

It was not clear how much the photograph has been worth to Slater, who previously said that fewer than 100 copies of his self-published book had been sold despite the publicity. His lawyer, Andrew Dhuey, was not immediately available for comment.

The case was brought in a U.S. court because Slater’s book was available for sale in the United States.