Television footage showed the bloody bodies lined up on the ground, most in their pajamas or naked.
Police said the attack took place at 4:30 a.m. in El Sauzal, a suburb of the resort of Ensenada and only 60 miles south of the U.S. border.
The Mexican television network Televisa said the victims were the residents of three neighboring houses in the middle-class town.
Children's toys littered the yard outside one concrete house, and at least one of the bodies seen on television was that of a baby.
Dozens of bullet casings surrounded the bodies, and the Televisa television network said most were from a Kalashnikov assault weapon, although some were from smaller-caliber weapons and shotguns.
Ensenada Judicial Police officer Jose Ramon Espinoza said the victims were members of three families: the Flores family and two families that both had the last name Castro. It was unclear whether the three families were related.
"It appears they rounded them all up, lined them up and gunned them down," Espinoza said.
He said he had no information on suspects or a possible motive.
Televisa gave the death toll at 19 and said there were two survivors.