Bill Withers, a onetime Navy aircraft mechanic who after teaching himself to play the guitar wrote some of the most memorable and often-covered songs of the 1970s, including “Lean on Me,” “Ain’t No Sunshine” and “Use Me,” died on Monday in Los Angeles. He was 81.

His death was announced in a statement from his family. His son, Todd, said he had heart problems.

Mr. Withers was in his 30s when he released his first album, “Just as I Am,” in 1971. It included “Ain’t No Sunshine,” a mournful lament (“Ain’t no sunshine when she’s gone/And she’s always gone too long/Anytime she goes away”) that cracked the Billboard Top 10. Other hits followed, perhaps none better known than “Lean on Me,” an anthem of friendship and support that hit No. 1 in 1972 and has been repurposed countless times by a wide variety of artists.

There were also “Use Me” (1972), “Lovely Day” (1977) and “Just the Two of Us” (1981), among other hits. But after the 1985 album “Watching You Watching Me,” frustrated with the music business, Mr. Withers stopped recording and performing.

Mr. Withers’s brief marriage to the actress Denise Nicholas in the 1970s ended in divorce. In 1976 he married Marcia Johnson. She and their son survive him, along with their daughter, Kori, and a sister, Florence Mather.