Neighbors had often complained about an unlicensed social club that operated on the first floor of a battered frame townhouse in Brooklyn. The space had a purple sign — “Triple A Aces Private & Social Event Space” — but it was being used as an illegal gambling den that attracted patrons in expensive cars, investigators and residents said.

Then, early on Saturday morning, gunfire erupted inside the sparsely furnished club in the Crown Heights neighborhood, where at least 15 people were playing card and dice games, the police said.

When the shooting stopped, four people were dead and three were wounded, the police said. It was the second mass shooting in Brooklyn in the last three months and the second quadruple homicide in New York City in a week.

The police said the motive for the shooting was not immediately clear, though investigators ruled out gang activity. Dermot F. Shea, the chief of detectives, said investigators were trying to determine if a “gambling dispute or a robbery” was behind the shooting. No suspects had been identified, he said.