SAN FRANCISCO -- Koko the gorilla, whose remarkable sign-language ability and motherly attachment to pet cats helped change the world's views about the intelligence of animals and their capacity for empathy, has died at 46.

Koko was taught sign language from an early age as a scientific test subject and eventually learned more than 1,000 words, a vocabulary similar to that of a human toddler.

She became a celebrity who played with the likes of William Shatner, Sting, Leonardo DiCaprio, Robin Williams and Mr. Rogers. At her home preserve, where she was treated like a queen, she ran around with Williams' eyeglasses and unzipped Roger's famous cardigan sweater.

In so doing, Koko showed the American public that a giant ape didn't have to be scary but wanted to be tickled and hugged.

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

Koko was the not the first animal to learn sign language and communicate, but through books and media appearances she became the most famous. Yet there was debate in the scientific community about how deep and human-like her conversations were.

Koko appeared in many documentaries, including a 2015 PBS one, and twice in National Geographic. The gorilla's 1978 National Geographic cover featured a photo that the animal had taken of herself in a mirror.

"Koko the individual was supersmart, like all the apes, and also sensitive, something not everyone expected from a 'king kong' type animal that movies depict as dangerous and formidable," Emory University primate researcher Frans de Waal said in an email Thursday.

"It changed the image of apes, and gorillas in particular, for the better, such as through the children's book 'Koko's Kitten' that may young people have grown up with. To view apes as nice and caring was new to the public and a big improvement."

Koko watched movies and television, with her handlers saying her favourite book was "The Three Little Kittens," her favourite movies included the Eddie Murphy version of "Doctor Doolittle" and "Free Willy," and her favourite TV show was "Wild Kingdom."

For her 25th birthday, she asked for and received a box of rubber snakes. In 1996, she even asked to be a mother. Despite attempts by her keepers to introduce male partners, Koko never became a mother. Instead, she had a series of kittens as pets.

The first was named All Ball, a grey and white tail-less kitten, given to Koko for her birthday in 1984. Other cats followed after All Ball's death, but researchers reported that the gorilla kept "mourning" the original cat years later.

Koko's real name was Hanabi-Ko, Japanese for fireworks child. She was born July 4, 1971, at the San Francisco Zoo.

Francine Patterson was working on her doctoral dissertation on the linguistic capabilities of gorillas and in 1972 started to teach Koko sign language. Patterson and biologist Ronald Cohn moved Koko to their newly established preserve in 1974 and kept teaching and studying her, adding a male gorilla in 1979.

In 2004, Koko used American Sign Language to communicate that her mouth hurt and used a pain scale of 1 to 10 to show how badly it hurt.

"Koko represents what language may have been 5 million years ago for people," Cohn said in 1996. "That's the time that gorillas and humans separated in evolution."

Other scientists, such as Herbert Terrace at Columbia University, who raised and taught sign language to a primate named Nim Chimpksy (a play on the name of the linguist Noam Chomsky), argued in scientific and popular literature that most of Koko's conversations and those of other primates were "not spontaneous but solicited by questions from her teachers and companions."

"Scientists have often complained about possible overinterpretation of Koko's sign language utterances and the lack of proper documentation of what she has said when and how," deWaal said in an email, adding that "coaching and interpretation by the people around her" may have altered her messages at times.

But the science, deWaal said, was "irrelevant to Koko's pop-image. ... Koko's passing is the end of an era, and a genuine loss."

Koko frequently asked to see people's nipples, a habit that led to controversy more than a dozen years ago, when two former caretakers said they were fired for refusing to bare their breasts to the gorilla. The women settled with the foundation in 2005.

Video shows Koko grabbing for Williams' chest area and Shatner's groin.

Williams, another San Francisco Bay area legend, met Koko in 2001 and called it a "mind-altering experience." The two held hands and tickled each other in a widely shared video.

"We shared something extraordinary: Laughter," he said. He called it "awesome and unforgettable." Williams killed himself in 2014.

Patterson later said she didn't plan on telling Koko about Williams' death, but the gorilla overheard conversation and then later "mourned" the actor by going silent and sullen.

Koko knew about death, primary researcher Patterson said in 2015, relaying in The Atlantic a conversation Koko had with another caretaker:

"The caregiver showed Koko a skeleton and asked, 'Is this alive or dead?' Koko signed, 'Dead, draped.' 'Draped' means 'covered up.' Then the caregiver asked, 'Where do animals go when they die?' Koko said, 'A comfortable hole.' Then she gave a kiss goodbye."

Borenstein reported from Washington.