"Like a Virgin" was written by Billy Steinberg and Tom Kelly. In an interview with the Los Angeles Times, Steinberg explained that the song was not only not written for Madonna, it was not even written for a female singer but was inspired by his personal experiences.
I wasn't just trying to get that racy word virgin in a lyric. I was saying ... that I may not really be a virgin – I've been battered romantically and emotionally like many people – but I'm starting a new relationship and it just feels so good, it's healing all the wounds and making me feel like I've never done this before, because it's so much deeper and more profound than anything I've ever felt.
Kelly recorded the demo, and invited Michael Ostin of Warner Bros. Records' A&R department to his house to listen to it. Steinberg and Kelly played four or five tunes for Ostin, and further discussed "Like a Virgin" – they were not sure for which artist the song would be suitable. Due to meet with Madonna the next day to discuss her sophomore album, Ostin intended on playing the demo to her, believing the lyrics and the groove of the song were perfect for Madonna. "When I played it for Madonna she went crazy, and knew instantly it was a song for her and that she could make a great record out of it," Ostin recalled. In 2009, Rolling Stone interviewer Austin Scaggs asked Madonna what her first impressions were after listening to the demos of "Like a Virgin" and "Material Girl". Madonna replied:
I liked them both because they were ironic and provocative at the same time but also unlike me. I am not a materialistic person, and I certainly wasn't a virgin, and, by the way, how can you be like a virgin? I liked the play on words, I thought they were clever. They're so geeky, they're cool. I never realised they would become my signature songs, especially the second one.