CAMBRIDGE, Mass. — When she was 15, the singer and songwriter Julien Baker had a suspicion: “Maybe God made me gay on purpose, and has chosen me for hell.”

It sounds like a precociously dark thought, but at that age, Ms. Baker was already moving past years of drug abuse and struggling to find the deeply held faith that now lives alongside doubt and self-laceration in her chiming, biting songs.

Over the past few months, Ms. Baker, now 20, has quickly built a sizable and devoted fan base. Her debut solo album, “Sprained Ankle,” initially self-released, was picked up by the independent label 6131 Records. Critics took notice, including Jon Caramanica of The New York Times, who named it one of the best albums of 2015. On Wednesday night, she performs at the Bowery Ballroom.

Growing up in Memphis, Ms. Baker, an only child, attended church with her mother and father, with whom she’s still close. Her parents separated when she was in elementary school, and the ritual fell away. Ms. Baker started spending more time with older kids, smoking and drinking, and eventually turning to hard drugs.