Hamlisch, who came from a Jewish family of Viennese origin, learned to play the piano at an early age and was considered a child prodigy. As a teenager he gave concerts at Town Hall. Then he studied at the Juilliard School of Music. Already in this time he shifted to composing. In 1965 he wrote his first hit with Sunshine, Lollipops and Rainbows for Lesley Gore, which he repeated in 1967, also for Gore, with California Nights. After hearing him play piano at a party, Sam Spiegel commissioned him to write his first film composition (for The Swimmer, 1966). He then moved to Los Angeles to be closer to the studios. His adaptations of Scott Joplin's ragtime compositions, which he wrote for the 1973 film The Sting, achieved great fame.
He wrote the music for many feature films and television series and for the successful Broadway musicals A Chorus Line and They're Playing Our Song. In 1977 Hamlisch also wrote the music for the James Bond film The Spy Who Loved Me (1977). He was also the conductor and arranger of Barbra Streisand's concerts from 1993, for whom he also wrote the 1973 number-one hit and million-seller The Way We Were. The cover version of Gladys Knight & the Pips was also a worldwide success.
Hamlisch was honored with numerous awards. Outstanding in this regard was the year 1974, when he was awarded a total of Oscars in three different categories. It followed in the further years seven Oscar nominations. Three times he could win the Emmy, twice a Golden Globe Award. Most often he received the ASCAP Award with four times.
Hamlisch died on August 6, 2012 after a short illness at the age of 68.