The attacks, carried out overnight in Sokoto, saw the gangs ride out from forest hideouts into villages with weapons.
Gunmen have killed dozens of people in a wave of attacks in northern Nigeria, the latest violence by criminal gangs raiding villages and stealing livestock.
The series of attacks, carried out overnight Saturday to Sunday in northwestern Sokoto state, left at least 43 dead.
“They opened fire on the village indiscriminately,” Abdullahi Dantani, from the village of Satiru where 18 people were murdered, told AFP news agency.
In Sokoto state’s Rabah district, gunmen rode into four villages – Rukunni, Tsage, Giire and Kalfu – killing 25 people.
“Several domestic animals were rustled by the attackers,” Ibrahim Kaoje, Sokoto state’s top police officer, told AFP.
Four people were arrested in connection to those attacks, Kaoje said.
In separate attacks in Satiru village, in Sokoto’s Isa district, the raiders shot 18 people, and then stole animals.
“We lost 18 people in the raid by the gunmen, who came into the village on motorcycles,” said Satiru village resident Umeh Na-Ta’ala.
The gangs have long been a scourge of rural communities in northern Nigeria, raiding villages, stealing cattle, burning homes, looting food and kidnapping for ransom.
The communities have taken up arms to defend themselves, although the vigilantes are often accused of extrajudicial killings of suspected bandits.
President Muhammadu Buhari condemned the killings, expressing “deep shock and sadness” in a statement issued late on Sunday.
“Perpetrators and sponsors of such dastardly acts (will) be held accountable,” Buhari said.
Human Rights Watch on Monday warned of a “dramatic uptick in banditry, kidnapping and killings” in the northwestern states of Kaduna, Katsina and Zamfara, which border Sokoto state.
“Security forces have failed to respond effectively to threats to people’s lives and security,” the rights group said.
The gangs are one of several security challenges facing Nigeria, including attacks by fighters from Boko Haram in northeastern regions, as well as battles between livestock herders and settled farmers.
These have left the military overstretched and seen Buhari criticised for failing to protect lives and property.
Buhari, who was sworn in last month for a second four-year presidential term, has promised to boost security.