LOS ANGELES — Filmmaker Stanley Donen, a giant of the Hollywood musical who through such classics as “Singin’ in the Rain” and “Funny Face” helped give us some of the most joyous sounds and images in movie history, has died. He was 94.

Donen, who often teamed with Gene Kelly but also worked with Cary Grant, Frank Sinatra and Fred Astaire, died Thursday in New York from heart failure, his sons Joshua and Mark Donen confirmed Saturday.

The 1940s and ’50s were the prime era for Hollywood musicals and no filmmaker contributed more to the magic than Donen, among the last survivors from that era and one willing to extend the limits of song and dance into the surreal. He was part of the unit behind such unforgettable scenes as Kelly dancing with an animated Jerry the mouse in “Anchors Aweigh,” Astaire’s gravity-defying spin across the ceiling in “Royal Wedding,” and, the all-time triumph, Kelly ecstatically splashing about as he performs the title number in “Singin’ in the Rain.”

Steven Spielberg recalled Donen as a “friend and early mentor” for whom life and film were inseparable.

“His generosity in giving over so many of his weekends in the late ’60s to film students like me to learn about telling stories and placing lenses and directing actors is a time I will never forget,” Spielberg said Saturday.

A 2007 American Film Institute survey of the top 100 American movies ranked “Singin’ in the Rain,” with its inventive take on Hollywood’s transition from silent to talking pictures in the 1920s and Kelly’s famous dance in a downpour, at No. 5.

Donen was asked in 2002 whether the filmmakers knew that “Singin’ in the Rain,” released in 1952 and also starring Debbie Reynolds and Donald O’Connor, would be revered decades later.

“You can’t get through a movie if you don’t think it’s good,” he said. “Certainly we thought it was good. More than that? I don’t know. You don’t think about that. You just think about how you can do it.”

Born in Columbia, S.C., Donen would remember movies — especially those with Astaire and Ginger Rogers— as a needed escape from the tensions of being one of the few Jews in his community. He took tap dancing lessons in his teens and began his show business career as a performer, dancing in the original Broadway production of “Pal Joey” at age 16. The title role was played by Kelly, and the show’s success propelled Kelly into the movies.

Donen received his first Hollywood break when Kelly got him a job helping choreograph the 1944 Kelly film “Cover Girl.” Over the next few years, he worked on choreography for such films as “The Kissing Bandit,” starring Sinatra, and “Take Me Out to the Ballgame,” starring Sinatra and Kelly, who teamed with Donen on choreography.

Other Donen films included “Seven Brides for Seven Brothers” (1954), with its superlative athletic choreography; “Damn Yankees” (1958), the remake of the Broadway smash about a baseball fan’s temptation; and “Funny Face,” in which Astaire teamed up with Audrey Hepburn to play a fashion photographer and his unlikely muse.

Astaire’s character in “Funny Face” was modeled on Richard Avedon, and the famed photographer served as a consultant to Donen.

Donen worked in various genres. “Indiscreet” (1958) was a light farce starring Grant and Ingrid Bergman, and “Two for the Road” (1967), with Hepburn and Albert Finney, was an unusually acerbic and tense marital comedy for its time, far removed from the carefree spirit of his musicals.

Donen himself was married five times and had an embroidered pillow in his New York apartment reading “EAT DRINK AND RE-MARRY.”