Square-jawed, with a dimpled chin, high forehead and mischievous eyes, Mr. Herman resembled Rock Hudson at the piano composing cabaret revues early in his career. One was his forgettable 1960 Broadway debut, “From A to Z,” for which he provided some of the songs, and which closed after 21 performances.

But his first full Broadway score, for “Milk and Honey” (1961), about American widows visiting Israel, got rave reviews, ran 543 performances and earned him a Tony nomination. The producer David Merrick was impressed, and asked him to compose samples for a musical based on “The Matchmaker,” Thornton Wilder’s farce about a widowed matchmaker who makes a match for herself. Mr. Herman was given a weekend.

“I produced those four songs in two days of the wildest, most intensive writing binge of my life,” he recalled in a memoir. “I was like a crazed person, pacing up and down in the middle of the night, scribbling down lyrics and popping candy in my mouth. But I was young, I was full of energy, and I wanted this happy, brightly colored American musical score more than anything in the world.”

Mr. Herman took his tunes and a singer to Mr. Merrick’s office. “It was like a scene from a movie,” he said. “Merrick, who is supposed to be pretty dour, stood up with a big smile after we finished singing and said, ‘Kid, the show is yours.’”