During 12 years as a youth librarian in northern Idaho, Denise Neujahr read to and befriended children of many backgrounds. Devout or atheist, gay or straight, all were welcome until a November evening in 2021, when about two dozen teens arriving at the Post Falls library for a meeting of the “Rainbow Squad” encountered a commotion at the entrance.

Members of a local church waved signs with images of hellfire and used a bullhorn to shout Bible verses and accusations about sin and pedophile “groomers” in the library. Parents had to escort the teens inside that night, and the library beefed up security. But the next month police arrested a protester outside the doors who was carrying a knife and a loaded gun.

In May, religious conservatives won a majority on the library board and named as its chair a member who had called the Rainbow Squad a “sex club.” Ms. Neujahr, who created the group as a program of crafts, snacks and conversation for L.G.B.T.Q. youth and their parents, said she was told the group’s funding was in danger. But she refused to disband it.

“They’re really good kids,” Ms. Neujahr said. “It just makes me so sad that they have to go through all this hate. This is not what libraries stand for.”

As America’s libraries have become noisy and sometimes dangerous new battlegrounds in the nation’s culture wars, librarians like Ms. Neujahr and their allies have moved from the stacks to the front lines. People who normally preside over hushed sanctuaries are now battling groups that demand the mass removal of books and seek to control library governance. Last year, more than 150 bills in 35 states aimed to restrict access to library materials, and to punish library workers who do not comply.