BRASILIA, Brazil—At least 12 young men were gunned down in separate incidents within hours of one another on the gritty outskirts of a university town, and investigators said Monday they're looking into whether police officers carried out the killings as revenge for the shooting death of a colleague in the same area.

The wave of killings began Sunday night and continued into early Monday in Campinas, a city of 1 million people known as the hub of Brazil's tech industry.

The mostly drive-by shootings of the young men occurred within about four hours of one another and came after an off-duty police officer was killed while fighting armed robbers who targeted him as he stopped at a gas station in the same region.

"We're not ruling out executions, revenge nor a fight between criminals," police investigator Licurgo Nunes Costa told the newspaper Estado de S. Paulo. "It's a sequence of events in the same region and around the same time, and we have to consider the relationship between the occurrences."

Police in Campinas, which is about 100 kilometers (60 miles) northwest of Brazil's biggest city, Sao Paulo, confirmed that the homicides took place, but wouldn't provide details on the cases.

About 30 people angrily protested over the killings, attacking commuter buses and burning at least three of them. There were no reported injuries in those cases.