The attack targeted residents of the town of Oicha in Congo's North Kivu province, a mineral-rich area that has been plagued with militia violence left over from a civil war that ended at the turn of the century.
The victims were tending crops around 20 km (12.43 miles) west of the town.
Oicha Mayor Nicolas Kikuku blamed members of the Allied Democratic Forces (ADF), an Islamic State-linked group originally from neighbouring Uganda that is now in east Congo and frequently attacks civilians.
By Wednesday evening, 17 bodies had been taken to the morgue of Oicha's general hospital on motorbikes, Kikuku said.
The head of the morgue, Kakule Sekera, said 19 bodies had been delivered so far, including two women. Some had their heads severed.
"The victims have been decapitated with machetes," Sekera said.
The vice-president of a local civil society group, Patrick Kakule Mukohe, said he had counted 17 bodies at the morgue so far but that he had heard of 31 victims in total.
"We think the other bodies will come later," he said.
(Reporting by Erikas Mwisi and Yassin Kombi Writing by Sofia Christensen Editing by Sandra Maler)

Soldiers from the Congolese Army Forces are seen in their forward operating bases around Mwenda, a small town that sits at the foot of the Rwenzori mountains, on April 7, 2021 in North Kivu, Democratic Republic of the Congo. It is close to Virunga National Park where a camp of ADF members live and hide. This town has been attacked multiple times by the ADF, with many civilians killed and some beheaded. A number of people including children have been abducted. As a result the Congolese army has a number of forward operating bases dotted around the area. The ADF is an Islamic terror group based out of Eastern DR Congo that, in recent years, has developed a relationship with the Islamic State after pledging allegiance to ISIS leadership. They are known locally as ISIS in Congo. ADF have killed over 5000 Congolese civilians in recent years, abducted and displaced thousands and killed over 2500 Congolese Army Soldiers. (Photo: Brent Stirton / Getty Images)