Hours later, gunfire erupted from behind an alley, authorities said.
Men, women and children fled toward the porch, where another attacker waited with an "AK-47-type weapon," said Stephen Zappala, the district attorney for Allegheny County.
The two gunmen killed six family members at the home in Wilkinsburg, including a woman who was 8 months pregnant.
Jessica Shelton was at the cookout Wednesday night, but left an hour before the shooting.
"I lost three children last night and two nieces ... it's just not right," a tearful Shelton said at a news conference Thursday.
Her children, Brittany Powell, Chanetta Powell and Jerry Shelton, died. So did their cousins, Tina Shelton and Shada Mahone.
Chanetta Powell was pregnant, and authorities are counting her fetus as one of the fatalities, Allegheny County police Superintendent Charles Moffatt said.
Shelton's 6-year-old grandson barely made it out alive, and later told his grandmother what happened.
"He said, 'Nana there was fireworks outside. Then I see mommy and them all laying on the ground. I didn't want the bad man to get me so I ran upstairs.' "
Shelton said some of her grandchildren are now orphans.
"For these shooters out here ... you just didn't take innocent lives, you made children lose their parents," she said.
3 others injured
In addition to the fatalities, three people were wounded. Two men are in critical condition while one woman was treated and released.
Investigators are looking into whether one of the men in critical condition, Lamont Powell, was the target, according to Mike Manko, a spokesman for the district attorney.
"Detectives have a number of theories they are working with," he said. "However, such a theory would do little to explain the indiscriminate shooting and killing of the other victims."
Powell is Shelton's son.
Attackers on the run
The unidentified attackers are believed to have escaped on foot and remain at large. Police talked to one victim at the hospital, but said they don't have enough for a description.
Zappala said it was the most brutal attack he's seen in his 18 years as a district attorney.
"It wasn't like he was just squeezing shots off randomly," he said. "They were all head shots. It was premeditated, it was calculated, it was planned."
Authorities recovered 48 shell casings at the scene.
While it's unclear whether the victims knew the gunmen, Zappala said retaliation may be a motive or there may be a drug connection.
"There's no indication that this was either a stash house or they were running an operation out of here," he said. "But drugs are definitely in play."
Jackie Johnson, who lives near the home in the Pittsburgh suburb, said she heard 30 bullets.
"When I came out, people were screaming and running," Johnson told CNN affiliate KDKA
. "And bodies were laying on the porch."
Another neighbor said he saw a bloody dog run out of the backyard with a bullet falling off its tail.
"People's lives taken like that, just on the drop of a hat," Johnson told the affiliate. "It's just insane. And it needs to stop. It has to stop."
Police and other law enforcement officials gathered Thursday outside the home, its siding pierced by bullets.
A red Bible and a white teddy bear sat at the doorstep.