Kim Peek, the real Rain Man whose almost unimaginable powers of memory were coupled with severe disabilities and who inspired the Oscar-winning film role played by Dustin Hoffman, has died of a heart attack in his home town of Salt Lake City, aged 58.

Peek has been called a "mega-savant" for his ability to memorise to the word up to 12,000 books, including the Bible and the Book of Mormon. He could read two pages in about 10 seconds – the right page with his right eye and the left simultaneously with his left eye.

He knew phone books by heart, and could tell you what day of the week a particular date fell upon going back decades. One of his party tricks was to tell strangers the names of the people who used to live next door to them years ago.

At the same time, though, he had deep disabilities and relied on his father Fran for help dressing, brushing his hair and other simple motor skills.

News of his death led to an outpouring of expressions of gratitude from thousands of parents of disabled children who said that the film, and Peek's many public appearances that followed it, had given them comfort and hope. "Kim taught us something about human potential beyond what most of us can even imagine let alone explain," said one commentator on his local paper, Deseret News.

"His legacy can be summed up in one word: inspiration," said Darold Treffert, a psychiatrist at the University of Wisconsin medical school who advised the makers of Rain Man and who was close to Peek for the past 20 years.

Peek was born on 11 November 1951 with damage to the cerebellum; the corpus callosum, the large bundle of nerves that connects the left and right hemispheres, was also missing.

At the age of two his severe disabilities almost landed him for life in an asylum.

In those days his condition was known as "idiot savant" and considered best treated in mental institutions. He was seen by a neurologist who famously could spare only five minutes as he was on his way to a golf course, and who concluded that the infant Kim would never be able to speak or learn and should be taken out of society.

Fran Peek, however, refused to accept that advice — after all by the age of two Kim could already read and memorise books. For the following 56 years, Fran acted as his son's primary carer, guide and loyal friend. "My dad and I share the same shadow," Kim once said.

Together, father and son toured the world, taking their story of the potential to overcome even seemingly intractable disabilities to more than 2 million people.

"You don't have to be handicapped to be different. Everybody is different," Kim would tell his audiences.

The Peeks lived in relative obscurity until 1984 when they attended a conference in Texas held by a group with the decidedly unreconstructed name Association for Retarded Citizens. There they met Barry Morrow, a Hollywood screenwriter who was looking for stories that had film potential.

"I was absolutely flabbergasted," Morrow has said of that meeting. "I could not get this man out of my mind."

When Hoffman was cast in the title role of the film Rain Man that Morrow wrote, based in spirit if not in detail on the life of Kim Peek, he spent time with Peek, imbibing his mannerisms and quirks. Film folklore has it that when Hoffman parted company with Peek, he said: "I may be the star, but you are the heavens."

Rain Man went on to take four Oscars, including best actor for Hoffman.

The film propelled Peek himself into a global phenomenon, though it never seemed to change him. He once wryly said: "I wasn't supposed to make it past 14 and here I am at 54, a celebrity."

Audiences clamoured to hear him answer questions off the top of his head, such as who was the game winning pitcher of game three of the 1926 World Series (Grover Cleveland Alexander of the Cardinals). They were stunned by his ability to rattle off facts in about 15 different subjects, including history, literature, sport and the British monarchy.

Brain scientists were equally eager to study him in the search for clues as to his extraordinary powers. In 2004 Nasa scientists scanned his brain to look at what happened when Peek expressed and thought of things.

Neurologist Elliott Sherr was part of a team at the University of California that was working with Peek at the time of his death, trying to understand the impact of the damage to his cerebellum. "His gift to the world was that he was a source of hope to others wherever he went," Sherr said.

Peek was initially diagnosed as having autism, but in recent years that view has been overturned.

Scientists remained intrigued by signs that over the years he seemed to acquire greater cognitive skills to interpret facts – something assumed to be lacking in savants.

He had begun to play the piano, and had developed something of a sense of humour. Before Rain Man he had shunned company and was incapable of looking people in the eye, but the film seemed to boost his confidence and social skills.

"He moved from holding this gigantic database of fact in his head to being able to join facts together," Treffert said. "He became a living Google."

• This article was amended on Wedneday 23 December 2009. We confused two parts of the brain in describing Kim Peek's medical condition. This has been corrected.