A gangbanger was settling the score with a rival crew when he wildly sprayed a Brooklyn street with gunfire — killing a hero mom as she shielded her child and other neighborhood kids, cops said yesterday.

Andrew Lopez, 18, who runs in a gang called 8 Block, confessed that he fired shots from a Pitkin Avenue rooftop at a crowd that included children filing out of PS/IS 298 in Brownsville Friday afternoon, authorities said.

The gunfire was intended for the rival Young Guns, who Lopez claims started a fight by throwing bottles at a group that included his halfbrother, Jonathan Carrasquillo, moments earlier.

“He made statements that he fired his weapon from the rooftop,” Police Commissioner Ray Kelly said. “We believe that Andrew’s brother was involved in a fight on the street.”

Carrasquillo, 22, allegedly told his halfbrother to get his gun moments before Lopez fired the 9mm pistol, killing Zurana Horton, 34, and wounding Cheanne McKnight, 11, and a 31-year-old woman.

Lopez and Carrasquillo were hit with a slew of charges, including murder, assault and reckless endangerment.

A third brother, Kristian Lopez, 17, was charged with weapons possession for going after the Young Guns crew with a baseball bat.

The bloodshed began when one of the brothers got a call that the Young Guns, who operate out of the nearby Howard Houses, “are outside fronting,” a source told The Post.

Horton, a mom of 13, was hailed as a hero for using her body to protect her child and other kids when gunfire erupted outside Lucky Supermarket.

Cops picked up the brothers at the Queens apartment of Carrasquillo’s girlfriend Monday night.

Horton’s stepfather, Kenneth Thompson, said he was glad that there was an arrest, but “it’s not going to bring her back.”

“It’s a great relief that someone has been caught,” he said, “but how many more crimes has he committed prior to this?”

Andrew Lopez has three arrests on his record: criminal possession of drugs in 2009, a sealed arrest in 2010 and resisting arrest and disorderly conduct on May 11, a law enforcement source said.

Carrasquillo’s priors include pot possession in 2006, disorderly conduct in 2007, resisting arrest, drug possession, robbery and trespassing in 2008, drug possession in 2009, trespassing in July and three sealed arrests in 2007 and 2008.

Kristian Lopez has a 2010 drug arrest, a sealed juvenile record and a weapons possession bust in 2010, sources said.

The family also has a history of violence on the same block where Horton was killed. Lopez’s halfbrother, Ismael Carrasquillo, is now serving 20 years for gunning down a man in March 2008.

Horton’s death caps an unthinkable triple tragedy for her mom, Denise Peace. Both of Horton’s brothers were fatally shot in Brooklyn, in 1991 and 2010.

“I hope [the suspects] get what’s coming to them, because it’s not right,” said Mary Johnson, a friend of Horton.