SAN LUIS POTOSI, Mexico — On a sunny afternoon last week, when the streets of this mountain mining city were filled with schoolchildren and parents hurrying home from work, gunmen entered a tiny apartment and started firing methodically.

The assassins killed everyone: the family matriarch and her adult son; her daughter and son-in-law, and finally, her 22-month-old granddaughter.

The child was not killed by mistake. Preliminary forensics indicate that the gunmen, unchallenged, pointed a pistol at Scarlett Ramirez and fired.

In Mexico’s brutal drug war, children are increasingly victims, innocents caught in the crossfire, shot dead alongside their parents — and intentionally targeted.

According to U.S. and Mexican experts, competing criminal groups appear to be killing children to terrorize the population or prove to rivals that their savagery is boundless, as they fight over local drug markets and billion-dollar trafficking routes to voracious consumers in the United States.

“It worries us very much, this growth in the attacks on little children. They use them as a vehicle to send a message,” said Juan Martin Perez, director of the Child Rights Network in Mexico. “Decapitations and hanging bodies from bridges send a message. Killing children is an extension of this trend.”

The children’s rights group estimates that 994 people younger than 18 were killed in drug-related violence between late 2006 and late 2010, based on media accounts, which are incomplete because newspapers are often too intimidated to report drug-related crimes.

Few of the crimes are solved. “What worries us is the impunity in all of these cases,” Perez said. “If there is impunity, this use of children to send messages will grow.”

Government figures include all homicides of people younger than 17, capturing victims whose murders might not have been related to drugs or organized crime. In 2009, the last year for which there is data, 1,180 children were killed, half in shootings.

Recent, sensational killings of children — shot in a car seat, dumped in a field with a bullet in the head, killed as their grandmothers cradled them — have shocked Mexicans and shaken their faith that family is sacred, even to the criminal gangs.

“Before, they went after their enemy. Now, they go after every member of the family, indiscriminately,” said Martin Garcia Aviles, a federal congressman from the Party of the Democratic Revolution from the state of Michoacan.

A Chihuahua state police commander was attacked as she carried her 5-year-old daughter to school two weeks ago. Both died of multiple gunshot wounds.

In February, assassins went hunting for a Ciudad Juarez man, but the intended target wasn’t home, so they killed his three daughters instead, ages 12, 14 and 15.

In March, a young woman was bound and gagged, shot and left in a car in Acapulco. Her 4-year-old daughter lay slumped beside her, killed with a single bullet to her chest. She was the fifth child killed in drug violence in the resort city in one bloody week.

“They kill children on purpose,” said Marcela Turati, author of “Crossfire,” a new book on the killings of civilians in Mexico’s drug war. “In Juarez, they told a 7-year-old boy to run, and shot his father. Then they shot the little boy.”

Once off-limits

Historians of the Mexican drug trafficking culture say that until recently children were considered off-limits in the rough code honored by crime bosses, who once upon a time liked to portray themselves as Robin Hoods dealing dope to gringos and donating alms to the poor.

“The rules no longer apply — rather, there are no rules,” said Bruce Bagley, an expert in the drug trade at the University of Miami. When the monolithic Institutional Revolutionary Party ruled Mexico, until 2000, Bagley said excess violence was tamped down by the state, which controlled the drug bosses with selective coercion and complicity.

Now no such “pacts” exist, Bagley said.

U.S. and Mexican officials say the grotesque violence is a symptom the cartels have been wounded by police and soldiers. “It may seem contradictory, but the unfortunate level of violence is a sign of success in the fight against drugs,” said Michele Leonhart, head of the Drug Enforcement Administration. The cartels “are like caged animals, attacking one another,” she added.

Earlier this month, the award-winning poet and commentator Javier Sicilia rallied at the main plaza in Cuernavaca and appealed directly to the drug lords “to return to your codes, where civilians are not touched, where civilians are sacred, where children are sacred.”

Sicilia’s 24-year-old son was found dead in March. His body and four others were stuffed into a compact car, their faces, wrists and ankles wrapped in tape, victims of suffocation. Next to the corpses was a message that read: “This happened to you for making anonymous calls to the military” and was signed “the Gulf Cartel.”

Young recruits

Children as young as 10 have been employed by crime gangs to watch over street corners or sell drugs, and in some cases to kill. In December, Mexican authorities arrested a 14-year-old boy who allegedly confessed that he worked as an assassin for $250 a week.

Edgar Jimenez Lugo told reporters that a drug trafficking gang kidnapped him when he was 11. “I participated in four executions. I was drugged. They said they would kill me,” he said.

Here in San Luis Potosi, violence between the La Familia cartel and ruthless Zetas group has roiled the once-quiet streets. People familiar with the latest murder of a child said the killers came looking for a rival. They didn’t find him — but they found his family.

“What malice, to kill the little girl,” said a neighbor whose children had played with Scarlett. He shook his head. “It’s incredible.”

Neighbors said the family worked hard. The little girl’s grandmother took in laundry. Her parents flipped hamburgers nearby.

Experts worry about the public health consequences of such violence. Schoolchildren in Michoacan were asked to create art for a contest commemorating the Mexican bicentennial, depicting scenes from everyday life in “the Mexico I live in.”

In late March, educators published a book of children’s drawings, which included a drug tough throwing a grenade at a federal policeman and a man being shot in the stomach with an automatic weapon.