Dark circles formed like warning signs beneath Yu Fen Wang’s eyes as she worked 12-hour graveyard shifts in a Queens maternity center that operated on the margins of legality. Her family said she had grown gaunt, could not sleep and told her husband she no longer wanted to live.

Her employers, however, said they needed her to work. And her family needed the money. She earned less than $100 a day, they said, working in a private house that had been converted into a combined nursery and hotel for newborn babies and their mothers.

An open secret in the Flushing community, the center was part of an underground industry catering to a demanding clientele: local mothers resting after childbirth and Chinese visitors coming to have their babies in the United States, a practice known as “birth tourism.”

On Sept. 21, at 3:40 a.m., these dangers collided to near-fatal effect when, the police say, Mrs. Wang stabbed three babies sleeping in bassinets on the first floor — all girls — and two adults. She then turned the knife on her own neck and wrists.