Koko, the gorilla who mastered sign language and counted the actor Robin Williams and Red Hot Chili Peppers bassist Flea among her friends, has died at age 46.

The Gorilla Foundation said the western lowland gorilla died in her sleep at the foundation's preserve in California's Santa Cruz Mountains on Tuesday.

Koko was born at the San Francisco Zoo, and Dr. Francine 'Penny' Patterson began teaching the gorilla sign language that became part of a Stanford University project in 1974.

She was said to be able to communicate with humans with 1,000 words of sign language and was able to understand 2,000 words of spoken English.

The foundation said Koko's capacity for language and empathy opened the minds and hearts of millions.

IT'S A BOY: GORILLA BABY IN LEIPZIG ZOO NAMED KIO

"The foundation will continue to honor Koko's legacy and advance our mission with ongoing projects including conservation efforts in Africa, the great ape sanctuary on Maui, and a sign language application featuring Koko for the benefit of both gorillas and children."

Koko appeared in several documentaries and twice in National Geographic in 1978 and 1985. The gorilla's 1978 cover featured a photo that the animal had taken of itself in a mirror.

The foundation said it will honor Koko's legacy with a sign language application featuring Koko for the benefit of gorillas and children, as well as other projects.

When “Good Will Hunting” actor Williams committed suicide in 2014, Koko was said to have been particularly upset.

The pair bonded in 2001 when Williams visited the foundation, and Koko insisted he tickle her and also wanted to try on his glasses.

Staff at the Gorilla Foundation explained to Koko that a friend of the center had died, which resulted in Koko hunching over in sadness and her lip quivering.

"Robin's ability to just 'hang out' with Koko, a gorilla, and in minutes become one of her closest friends, was extraordinary and unforgettable," Patterson wrote at the time.

The Associated Press contributed to this report