Clinton called Hamlisch, whose casket was covered in his favorite yellow freesias, a "great, giving genius." Sir Howard Stringer, chairman of Sony Corp., called him "the merriest of minstrels."
Hamlisch died Aug. 6 in Los Angeles after a short illness. He was 68.
Other guests included ex-Yankee manager Joe Torre, Kelli O'Hara, Ann-Margret, Raul Esparza, Robert Klein, Brian Stokes Mitchell, Leslie Uggams, Richard Gere, Tony Danza, Kathie Lee Gifford and Diane Sawyer and her husband Mike Nichols, the film and stage director.
"Genius is rare enough, but a good-hearted genius is rarer still. A good-hearted, humble and hilarious genius is almost unheard of," said Clinton.
Hamlisch composed or arranged hundreds of scores for musicals and movies, including "A Chorus Line" on Broadway and the films "The Sting," "Sophie's Choice," "Ordinary People" and "The Way We Were."
His funeral was held at Congregation Emanu-El, a prominent Manhattan synagogue where legendary songwriter George Gershwin's funeral was held in 1937.
Speakers, including composer Richard Kagan, cosmetics executive Leonard Lauder and socialite Lily Safra, described a friend always willing to help a good cause, who was a bashful philanthropist and a devoted Yankee fan who would ask for the latest scores before stepping onstage.
A choir that included fellow composers, lyricists and musicians such as Lucie Arnaz, Rupert Holmes and Sheldon Harnick, sang "The Way We Were" and "What I Did for Love." Statements of mourning were read from President Barack Obama and former first lady Nancy Reagan.
Hamlisch is survived by his wife of 26 years, Terre, who took the podium and shared memories of a man whose "life force was huge.
"Marvin taught me how to live life with gusto and magic," she said. "He would order every dessert on the menu so everyone could taste everything and miss nothing in life."
Hamlisch, who became the youngest person accepted by The Juilliard School at age 7, became one of the most decorated artists in history, winning three Oscars, four Emmys, four Grammys, a Tony, a Pulitzer and two Golden Globes.
His versatility, classic melodies and ear for musical hooks meant he was as comfortable writing songs for Barbra Streisand as he was for a light Woody Allen comedy like "Bananas.
He wrote everything from the title song for the TV series "Brooklyn Bridge" to the stunning score for the movie "The Swimmer" to the symphonic suite "Anatomy of Peace." He also wrote the original theme song for ABC's "Good Morning America."
Hamlisch received both a Tony and the Pulitzer for "A Chorus Line"—the second longest-running American show in Broadway history—and wrote the music for other stage hits such as "The Goodbye Girl" and "Sweet Smell of Success."
Hamlisch's reach extended into the pop world, writing the No. 1 R&B hit "Break It to Me Gently" with Carole Bayer Sager for Aretha Franklin. He co-wrote "One Song" sung by Tevin Campbell and produced by Quincy Jones, and "I Don't Do Duets" sung by Patti LaBelle and Gladys Knight.
He was working on a new musical, "Gotta Dance," at the time of his death and was scheduled to write the score for a new Soderbergh film on Liberace, "Behind the Candelabra," starring Michael Douglas and Matt Damon. In Nashville, Tenn., the Tennessee Performing Arts Center is producing his new musical production of "The Nutty Professor," directed by Jerry Lewis.
Hamlisch also enjoyed holding a baton, conducting orchestras in Pittsburgh, Milwaukee, Dallas, Seattle and San Diego, among others. At the time of his death, he was to be announced as the principal pops conductor of the Philadelphia Orchestra. And on New Year's Eve, he was to conduct a concert with the New York Philharmonic.
Outside the synagogue, Uggams recalled Hamlisch's great sense of humor, while Danza called him "one of the truly greats." Torre said: "I was probably just as much a fan of his as he was of mine."
Esparza remembered auditioning for "Sweet Smell of Success" as a young actor. He didn't get a part, but Hamlisch stopped him later at a restaurant and told him he wished they had cast him and thought Esparza was going to be huge. "You know what? For a guy who is starting out, to hear that from Marvin Hamlisch at a diner, that's huge."