A writer by trade - and a journalist by education - David had a knack for encapsulating love, earnestness and a wry sense of humor into a melody that was just a few minutes long. "Wishin' and Hopin'," the 1960s earworm he wrote with Burt Bacharach, was a rhyming how-to for gals looking to snag a man. With a wink, it snagged a new generation of fans when it opened the 1997 Julia Roberts film "My Best Friend's Wedding."
Through theater, film and TV, David's songs transcended the time they were written to become classics. With Bacharach, he was one of the most successful songwriting teams in modern history.
The 91-year-old, who died Saturday of complications from a stroke four days earlier in Los Angeles, "always had a song in his head," said his wife, Eunice David. Even at the end, "he was always writing notes, or asking me to take a note down, so he wouldn't forget a lyric."
Bacharach and David's hits included "Raindrops Keep Fallin' On My Head," ''(They Long to Be) Close to You" and "That's What Friends Are For." Many of the top acts of their time, from Barbra Streisand to Frank Sinatra and Aretha Franklin, recorded their music.
But the collaboration for which they were best known came in 1962, when they began writing for a young singer named Dionne Warwick.
Warwick's versatile voice could convey the emotion of David's lyrics and handle the changing patterns of Bacharach's melodies. Together the trio created a chain of hits: "Don't Make Me Over," ''Walk On By," ''I Say a Little Prayer," ''Do You Know the Way to San Jose," ''Always Something There to Remind Me" (which later was a hit for the 1980s synth pop band Naked Eyes), among others.
They were a "triangle marriage that worked," Warwick wrote in her memoir, "My Life, As I See It." Bacharach was "the handsome one," and David was level-headed - a "thoughtful, gentle, sincere" man - Warwick wrote.
Ever the writer (he studied journalism at New York University), David said in a 1999 interview that he thought of songwriting as telling a narrative.
"The songs should be like a little film, told in three or four minutes. Try to say things as simply as possible, which is probably the most difficult thing to do," he said.
The New York-based writer often flew to Los Angeles, where he and Bacharach holed up for weeks of intense songwriting. They also conferred by telephone, a method that birthed "I Say a Little Prayer."
When a song went nowhere, they stuck it in a desk drawer and left it there for months.
In a brief essay on his website, David recalled having an idea for a song for "at least two years before showing it to Burt."
"I was stuck," he wrote. "I kept thinking of lines like, 'Lord, we don't need planes that fly higher or faster ...' and they all seemed wrong. Why, I didn't know. But the idea stayed with me.
"Then, one day, I thought of, 'Lord, we don't need another mountain,' and all at once I knew how the lyric should be written. Things like planes and trains and cars are manmade, and things like mountains and rivers and valleys are created by someone or something we call God. There was now a oneness of idea and language instead of a conflict. It had taken me two years to put my finger on it."
And so they had another smash: "What the World Needs Now is Love."
David and Bacharach met when both worked in the Brill Building, New York's legendary Tin Pan Alley song factory where writers cranked out songs to sell to music publishers. They scored their first big hit with "Magic Moments," a million-selling record for Perry Como.
Their success transferred to film and theater, where they won an Oscar for "Raindrops Keep Fallin' on My Head" (from the movie "Butch Cassidy and the Sundance Kid"), and Grammys and Tonys for the songs from the hit Broadway musical "Promises, Promises."
But the hit-making team broke up after the 1973 musical remake of "Lost Horizon." The pair and Warwick had devoted two years to the movie, which was scorned by critics and audiences. Bacharach then sequestered himself in his vacation home and refused to work.
Bacharach and David sued each other, and Warwick sued them both. The cases were settled out of court in 1979 and the three went their separate ways. They reconciled in 1992 for Warwick's recording of "Sunny Weather Lover."
David went on to collaborate successfully with other composers: John Barry with the title song of the James Bond film "Moonraker;" Albert Hammond with "To All the Girls I've Loved Before," which Julio Iglesias and Willie Nelson sang as a duet; and Henry Mancini with "The Greatest Gift" in "The Return of the Pink Panther."
David joined the board of the American Society of Composers, Authors and Publishers in 1974 and served as president 1980 to 1986. He was head of the Songwriters Hall of Fame from 2001 to 2011, and was chairman emeritus at his death.
"As a lyric writer, Hal was simple, concise and poetic - conveying volumes of meaning in fewest possible words and always in service to the music," ASCAP president, the songwriter Paul Williams, said in a statement. "It is no wonder that so many of his lyrics have become part of our everyday vocabulary and his songs... the backdrop of our lives."
In May, Bacharach and David received the Library of Congress Gershwin Prize for Popular Song during a White House tribute concert attended by President Barack Obama. David, recovering from a major stroke in March, did not attend, but his wife accepted on his behalf.
"It was thrilling," she said. "Even though he wasn't there, Hal said it was the highest honor he had ever received."
Obama noted their music is still being recorded by such artists as Alicia Keys and John Legend.
"Above all, they stayed true to themselves," Obama said. "And with an unmistakable authenticity, they captured the emotions of our daily lives - the good times, the bad times, and everything in between."
Born in New York City, David attended public schools and NYU, then served in the Army during World War II, mostly as a member of an entertainment unit in the South Pacific. After the war, he was a copywriter at the New York Post and wrote lyrics for bandleaders before hooking up with Bacharach.
He married Anne Rauchman in 1947, and together they had two sons.
Singer Smokey Robinson called on others to honor David's musical legacy.
"I hope that the music world will join together in celebrating the life of one of our greatest composers ever," he said.
AP National Writer Hillel Italie contributed from New York.