Motorcycle-riding attackers struck late on Monday at a goldmine outside Bindin village in northern Zamfara state, shooting dead miners and gold merchants, they said.
The state governor condemned the attack "in strongest terms" in a government statement, describing it as an "act of terrorism".
The statement said an investigation had been launched, while local residents said it was just the latest deadly raid by cattle thieves on herding communities in the state.
"We buried 36 bodies of those killed in the attack today. For us it is a day of mourning," he said.
More From This Section
Zamfara is known for its huge gold deposits and mines still using traditional methods. A local chief said the gunmen entered the mine tunnels, shooting dead the miners after killing traders standing at the surface.
Many local herders and subsistence farmers turn to gold mining to boost their income.
Rural communities in the state have long been plagued by cattle thieves, who kill villagers, loot and torch homes, prompting locals to form vigilante groups to fight off the gangs.
Attacks by nomadic Fulani herdsmen on farmers have been a persistent headache for Nigeria this year, adding to security woes in a country already grappling with the Boko Haram Islamist insurgency.
The mainly Muslim Fulani herders and largely Christian farmers have clashed for decades over increasingly scarce land and resources, particularly in Nigeria's religiously mixed central states.
But the violence has escalated in recent months and spread further south.
In February, hundreds of people were said to have been killed and about 1,000 homes destroyed in central Benue state in a wave of attacks blamed on Fulani.