The attack took place late on Sunday in Guyaku, a village in the Gombi local government area in the country’s Adamawa state, according to the state governor.
The Islamic State group claimed responsibility for the attack in a message on the Telegram messaging app.
Adamawa State Governor Ahmadu Umaru Fintiri denounced the attack as tragic and unacceptable during a visit to the village on Monday.
Nigeria is facing myriad security challenges, especially in the north, where an insurgency has simmered for more than two decades. In February, the United States sent troops to the West African nation to help advise its military on the fight against insecurity.
There are two major IS-backed terrorist groups in Nigeria but it wasn't immediately clear which one was behind the attack in Guyaki.