Military escort women out of Kaduna, Nigeria, on June 19, after rioting that broke out after religious violence left over 50 dead.

Story highlights

NEW: Gunfire kills 23, wounds 17 at a northern Nigeria marketplace

NEW: Authorities believe a criminal gang was behind the attack

The victims had left a nearby mosque after morning prayers

CNN  — 

Investigators suspect a criminal gang was behind the Sunday morning killings of nearly two dozen men in a marketplace in northern Nigeria, a government official said.

The killings took place near a mosque in the village of Dogon Dawa, in the northern state of Kaduna. The attackers left 23 dead and 17 wounded, said Musa Ilallah, a regional coordinator with Nigeria’s National Emergency Management Agency.

Read more: Police arrest 13 in videotaped killings in Nigeria

“Today is a market day at the village, so many people were out shopping,” Ilallah said.

The victims, all of them men, had just left morning prayers at a nearby mosque, he said.

The surrounding district is notorious for armed robberies, and Dogon Dawa is surrounded by a forest that criminals use as a hideout. Ilallah said he was sure the attack was aimed at villagers who participate in a community watch group, “because they expose the criminals and their hideouts to police.”

Opinion: Why are Nigerians numb to slaughter?

“I’m sure the Nigerian government will further investigate and take action to ensure this mass killing does not happen again,” he said.

The victims of Sunday’s attack were farmers, village chief Suleiman Zuberu told CNN.

Kaduna has been the scene of deadly clashes between Nigerian Christians and Muslims, including a spate of attacks on churches in June that left 50 people dead. The Islamic militant group Boko Haram, which is fighting to replace Nigeria’s government with a fundamentalist Islamic state, claimed responsibility for those killings.

Opinion: Could it finally be springtime for Nigeria?

CNN’s Nana Karikari-Apau contributed to this report.