In 2011, Naruto, a curious 6-year-old monkey in Indonesia, peered into a camera lens, grinned and pressed the shutter button on the unattended camera. Little did the endangered crested macaque know that he may have been providing for his future.

The selfie of his bucktooth smile and wide amber eyes made Naruto an internet celebrity. But the widely shared image became embroiled in a novel and lengthy lawsuit over whether the monkey owned the rights to it. Naruto lost the first round in federal court in California in 2016, but won a victory of sorts in a settlement on Monday for himself and his friends.

The camera’s owner, David J. Slater, agreed to donate 25 percent of future revenue of the images taken by the monkey to charitable organizations that protect Naruto, who lives in the Tangkoko Reserve on the Indonesian island of Sulawesi, and other crested macaques. Lawyers for Mr. Slater, a British photographer, and People for the Ethical Treatment of Animals, which sued Mr. Slater on Naruto’s behalf, also asked the United States Court of Appeals for the Ninth Circuit, which was hearing an appeal in the case, to drop the lawsuit and vacate a lower decision that found the monkey could not own the image’s copyright.

“PETA and David Slater agree that this case raises important, cutting-edge issues about expanding legal rights for nonhuman animals, a goal that they both support, and they will continue their respective work to achieve this goal,” the groups said in a joint statement on Monday.