Nancy Garden, the author of the young-adult novel “Annie on My Mind,” died June 23 at 76. (Courtesy of Macmillan Children’s Publishing Group)

Nancy Garden, the author of the novel “Annie on My Mind” and other volumes that helped young readers explore themes of gay romance and self-discovery when few books offered such an outlet, died June 23 at her home in Carlisle, Mass. She was 76.

The cause was an apparent heart attack, said her partner, Sandra Scott.

Ms. Garden wrote several dozen books, including works of fantasy and historical fiction. She was best known for “Annie on My Mind” (1982), which has been recognized as an important contribution to young adult literature.

The novel centers on two high school students in New York, Liza and Annie, who meet at the Metropolitan Museum of Art and fall in love.

When the novel first appeared on bookshelves, few if any other young-adult writers had depicted gay romance with such candor or sensitivity.

“Annie on My Mind,” shown in its 2007 edition, was first published in 1982. (Courtesy of Macmillan Children’s Publishing Group)

“Nancy Garden has the distinction of being the first author for young adults to create a lesbian love story with a positive ending,” declared the committee chairwoman when Ms. Garden received the Margaret A. Edwards Award for youth literature in 2003. “Using a fluid, readable style, Garden opens a window through which readers can find courage to be true to themselves.”

Ms. Garden said she was inspired to write the book to help fill a void that she had experienced as a young reader.

“When I was growing up as a young lesbian in the ’50s, I looked in vain for books about my people,” she told the young-adult author Cynthia Leitich Smith in an interview. “I did find some paperbacks with lurid covers in the local bus station,” she continued, “but they ended with the gay character’s committing suicide, dying in a car crash, being sent to a mental hospital or ‘turning’ heterosexual.”

After reading “Annie on My Mind,” Ms. Garden remarked in an interview, gay readers told her that it had made them feel less alone and helped them come out. Straight readers, she said, admired it as a love story.

In one passage of the book, Ms. Garden described the characters’ growing relationship. “I stood in the kitchen leaning against the counter watching Annie feed the cats,” reads the narration, “and I knew I wanted to be able to do that forever: stand in kitchens watching Annie feed cats. Our kitchens. Our cats.”

The novel encountered opposition over the years from some educators, parents and others who regarded its topic matter as inappropriate.

The American Library Association has ranked it among the most commonly challenged books. The book has been burned, according to news accounts.

In one noted case in the 1990s, students and parents successfully sued to keep it on bookshelves at their school library in Olathe, Kan.

Ms. Garden became known as a forceful advocate against censorship.

“I think kids in every minority need to see people like themselves in books,” she told Leitich Smith. “That’s an acknowledgment of their existence on this planet and in this society.”

Antoinette Elisabeth Garden was born May 15, 1938, in Boston. (She went by Nancy for many years, later adopting it at her legal name.)

As a young woman, Ms. Garden aspired to be an actress. She received a bachelor’s degree in fine arts from Columbia University in 1961 and a master’s degree the following year from Columbia’s teachers college.

In the early years of her career, she worked in theater, as a teacher and later in publishing before turning to writing full-time. Her first published books included “What Happened in Marston,” about racial discord in a small community, and “Berlin: City Split in Two,” which stemmed from her own coming of age during the Cold War. Both were released in 1971.

She penned stories about werewolves, vampires and witches. In the historical genre, she wrote “Dove and Sword” (1995), a novel about Joan of Arc. Ms. Garden’s novel “Peace, O River” (1986) dealt with prejudice and class conflict.

After writing “Annie on My Mind,” Ms. Garden returned to the theme of lesbian love in “Good Moon Rising” (1996). In “Holly’s Secret” (2000), she wrote about a young woman who has two mothers. In “The Year They Burned the Books” (1999), she wrote about gay youths who meet conservative resistance in their town.

Her only immediate survivor is her partner of more than 40 years, Sandra Scott of Carlisle. They were marred in 2004.

Ms. Garden received many letters from her young readers and the grown-ups who cared about them. One letter, she recalled, came from a teacher who said he was convinced that “Annie on My Mind” had prevented a student from committing suicide.

That, Ms. Garden said, was “perhaps the most moving comment of all.”