His year for the record books was 1973, when he co-wrote the music for "The Way We Were" with Marilyn and Alan Bergman. The theme song at first failed to impress Streisand, who thought it was too simple musically. Hamlisch said he had to beg her to sing it, and she agreed only after the rest of the cast out-voted her. It became one of her signature songs.
Hamlisch shared the Oscar for best original song with the Bergmans and also won the Oscar for best original dramatic score. At the same Academy Awards ceremony, he won an Oscar for his adaptation of Scott Joplin's ragtime music for "The Sting," the 1973 movie starring Paul Newman and Robert Redford as two 1930s con men. Hamlisch's lush orchestrations have been credited with reviving interest in Joplin's music.
When the composer got up to receive his third Oscar of the night, he quipped, "I think we can now talk to each other as friends."
He stormed Broadway the following year, 1975, when "A Chorus Line" opened to generally glowing reviews.
The backstage musical conceived, choreographed and directed by Michael Bennett and based on the book by James Kirkwood Jr. and Nicholas Dante ran for more than 6,000 performances. It became the longest-running production in Broadway history until it was surpassed by "Cats" in 1997. It also won nine Tonys, including best musical score for Hamlisch and lyricist Edward Kleban.
Several of the Hamlisch-Kleban tunes became hits, including "One" and "What I Did for Love," which has been recorded by Jack Jones, Tony Bennett, Johnny Mathis and Andy Williams, among others.
It was one of only seven musicals to win a Pulitzer Prize and, among Hamlisch's many contributions to American music, it is the one that "will keep him alive for generations to come," said Miles Kreuger, president of the Los Angeles-based Institute of the American Musical.
Despite the many honors Hamlisch earned, he remained highly susceptible to self-doubt. As he wrote in his 1992 memoir, "The Way I Was," he was crushed by a negative comment in an otherwise enthusiastic review of "Chorus Line" by the New York Times' Clive Barnes, who wrote that Hamlisch's music was only "occasionally hummable." Hamlisch wrote that he was so distraught he locked himself in his apartment for days.
A self-described "square," he rarely went without a suit and tie and wore thick black-framed glasses that inspired Gilda Radner's "Nerd" sketches for"Saturday Night Live." He spent many Saturday nights alone because, he told CNN interviewer Sonya Friedman in 1992, "I learned that success only brings you success."
His next Broadway outing was in 1979 with Neil Simon's "They're Playing Our Song." With music by Hamlisch and lyrics by Carole Bayer Sager, it starred Robert Klein and Lucie Arnaz as two songwriters ensnared in a stormy relationship and was said to have been based on Hamlisch's relationship with Bayer Sager. It ran for more than 1,000 performances and later opened in London.
He had collaborated with Bayer Sager on "Nobody Does It Better," the theme song for the 1977 James Bond movie "The Spy Who Loved Me." It became a hit for singer Carly Simon.
He also wrote the score for the 1986 Broadway production "Smile," based on the film comedy of the same name. It closed after only 48 performances, sending Hamlisch into a long depression during which "all I could do was eat myself up alive," he told the Los Angeles Times in 2002.
In 1989 his marriage to television reporter and producer Terre Blair after a long-distance courtship made life rosy again. "She redirected my freneticism," he told the San Francisco Chronicle in 1992. She survives him.
His other film work included scores for the Oscar-winning films"Ordinary People"(1980) and "Sophie's Choice" (1982). Hamlisch also composed the music for the 2002 Tony-nominated musical "Sweet Smell of Success."
He ventured into classical music with "Anatomy of Peace," a composition based on a 1945 book by Emery Reves and performed by the Dallas Symphony in 1991.
But he acknowledged that his chief joy was writing popular music. "The biggest thrill you can have is to tell people one of your songs," he once said, "and have them be able to hum it."
Times staff writers Valerie J. Nelson and Susan King and researcher Kent Coloma contributed to this report.