Madonna worked on the album with Stephen Bray and Patrick Leonard, who she collaborated with for 1986’s True Blue. She also enlisted the help of fellow icon Prince for their duet on “Love Song”. Prince also played guitars (uncredited) on three songs—”Like a Prayer”, “Keep It Together” and “Act of Contrition.” Madonna co-wrote and co-produced every song on the album. Recording began in September 1988 and continued until January 1989. Madonna and her husband Sean Penn filed for divorce in January 1989, following a nullified divorce filing in late 1987 and several well-publicized fights involving Penn, one of which led to a 60-day prison term. The incident inspired the song “Till Death Do Us Part”, which details the failed marriage. Like a Prayer developed an introspective theme, utilizing confessional lyrics about personal issues. Madonna described the album as a collection of songs “about my mother, my father, and bonds with my family. […] It’s taken a lot of guts to do this.” It was claimed the album was her “most different” work to date.
Like a Prayer was dedicated to Madonna’s mother, who died when Madonna was five. The songs “intertwine her search for faith with her search for her mother.” Madonna’s struggle with religion inspired the album. “The theme of Catholicism runs rampant through my album”, she said. “It’s me struggling with the mystery and magic that surrounds it. My own Catholicism is in constant upheaval.” “The album is drawn from what I was going through when I was growing up”, Madonna told Rolling Stone. She added, “I’m still growing up.”