Whatever his subject matter, the composer-lyricist Michael Friedman created songs that were triumphs of empathy.

The Boston-born, Philadelphia-raised theater composer, who died Saturday at age 41 in New York from an HIV-related infection, researched his many off-Broadway shows like a documentarian. He put President Andrew Jackson on Broadway in Bloody Bloody Andrew Jackson, but also dramatized everyday people, from born-again Christians to pornography stars, with the characters expressing themselves in the kind of songs they could have written themselves — had they had his talent.

"Our possessions are only shadows, echoes of fate, the things you lose you never possessed," were his lyrics in the 2003 Gone Missing, a cabaret revue about what New Yorkers misplace.

"If you squint your eyes and don't look back," sang a hapless porn star, regarding the movie sets in the 2015 Pretty Filthy, "it feels like home."

Benj Pasek, a fellow lyricist and Philadelphian, called Friedman's death "a shocking and devastating loss."

Whether he wrote songs or incidental music for plays, his work took the tone of his subject matter — plus the production around it. For Romeo and Juliet at the Williamstown (Mass.) Theatre Festival, he had a Mexican rock band onstage. For Shakespeare in the Park in New York, he underscored the final death scene with quiet classical guitar.

In 2015, Friedman toured the country interviewing a wide variety of people about the forthcoming election, writing songs about their positions on numerous hot-button issues for the New Yorker Radio Hour in what became the State of the Union Songbook. His latest show, The Abominables, is about hockey culture, and opens at Children's Theatre Company in Minneapolis this week.

Since 2001, as a founding member of theater collective the Civilians, Friedman had specialized in exploring unconventional subject matter. For This Beautiful City, he witnessed thousands of people speaking in tongues at an evangelical community in Colorado, and expressed great fondness for those he met and interviewed while researching the show. "I tend to go where I'm needed," he said in 2007, "but when I get there, I'm writing for and from myself. I'm trying to re-create a world."

He had not been ill long, said his father, John, a former marketing director for the Inquirer and Daily News. A single gay man, Michael Friedman received his HIV diagnosis in July during a routine examination, and until last Thursday the prognosis for the opportunistic infections that followed had been good.

John Michael Friedman III — always known as Michael —  wrote songs and even a challenging choral work titled Icarus during his years at Germantown Friends School, where he graduated in 1993. Friedman was such an accomplished pianist that he performed Ravel's Piano Concerto in G during those years, said Lawrence Hoenig, the school's music department director at the time. Yet he concentrated on history at Harvard University rather than pursuing purely musical training at Temple University. "He was a brilliant thinker and needed more in the education department than what a conservatory could offer," Hoenig said.

At Harvard, he studied music with strictly classical Bernard Rands and, more significantly, with the late composer/director Elizabeth Swados, who blurred genres and took on serious subject matter. "He could always put poems to music, but at age 25, he realized he could write words as well, and started writing songs," his father said.

The creative key was collaboration. "That was everything to him," said his father. His influences ranged from Stephen Foster to modern soul music.

Though he returned to Philadelphia to see family, his work here mainly consisted of songs for the 2009 Welcome to Yuba City! at Pig Iron Theatre. With director Michael Greif (Dear Evan Hansen), Friedman adapted the John Travolta TV movie The Boy in the Plastic Bubble. He was artistic director at Encores! Off-Center at New York City Center, which presented off-Broadway musicals, and was public forum director and artist in residence at New York's Public Theater.

Future plans included a musical version of All the President's Men. He was also having preliminary talks with the Metropolitan Opera about a new version of The Magic Flute. "He always had eight irons in the fire," said his father, adding that much of it was "five to 10 years on the horizon."

Though Friedman was nominated for numerous awards, his most meaningful nod came with a 2007 Obie Award for sustained excellence. His legacy rests mainly with Bloody Bloody Andrew Jackson, which began off-Broadway in 2008, opened on Broadway in 2010, and is now a fixture in regional theater. Several of his shows have been recorded; Pretty Filthy came out on the Ghostlight label last year.

In addition to his father, he is survived by his mother, Carolyn, and a sister.

A memorial service will be held at 11 a.m. Saturday at Germantown Friends School, 31 W. Coulter St.