(Reuters) - Monkeys lack standing to sue for copyright protection and an animal rights group cannot act as legal guardian in such matters, a U.S. appeals court ruled on Monday, in a battle over ownership of a smiling “selfie” taken by an endangered macaque.

The dispute stemmed from a famous image that Naruto, a rare crested macaque who lives on an nature reserve, snapped using a camera that British photographer David Slater left mounted and unattended during a 2011 trip.

His grinning visage, which Slater published in a wildlife book, went viral and triggered the long-running legal battle over who had the copyright, the animal who snapped the picture or the nature photographer who owned the camera.

“The panel held that the monkey lacked statutory standing because the Copyright Act does not expressly authorize animals to file copyright infringement suits,” said the judges of the 9th U.S. Circuit Court of Appeals based in San Francisco.

Their opinion added that the group, People for the Ethical Treatment of Animals (PETA), which filed as a plaintiff on behalf of Naruto, was not a “next friend” of the monkey in a legal sense and failed to establish that it had a significant relationship with him.

“Denying him (Naruto) the right to sue under the U.S. Copyright Act emphasizes what PETA has argued all along — that he is discriminated against simply because he’s a nonhuman animal,” Jeff Kerr, the general counsel to PETA, said in a statement.

PETA had argued 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.

A settlement was reached out of court in the case last year. Attorneys for Naruto and Slater announced that Slater had agreed to donate 25 percent of future revenue from the photograph to charitable groups that protect Naruto and other members of his species in Indonesia.

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.

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