Twenty people died following explosions at a military checkpoint outside the north-eastern town of Biu.
Troops present at the checkpoint fired back, killing 17 of the insurgents. It is believed they were from Boko Haram.
On Tuesday the group released a video in which Boko Haram's leader, Abubakar Shekau vowed to disrupt Nigeria's elections at any cost.
The 15-minute film was released via the group's newly created Twitter account, prompting some analysts to question whether they had been influenced by Islamic State.
Previous Boko Haram videos were of a lower quality and distributed to journalists on DVD.
Also on Tuesday, a suicide bomber killed four and injured five at a restaurant near a military checkpoint in Potiskum, north-eastern Nigeria.
Meanwhile an attack at an opposition rally in the south of the country killed one police officer and injured four others, while a reporter covering the event was stabbed, according to news agency AFP.
The attack targeted a rally by the All Progressives Congress (APC) - Nigeria's main opposition - in Okrika, a small port town south of Port Harcourt in the heart of Nigeria's oil-producing region.
APC members were waiting for the rally to begin, witnesses said, when there was several explosions and gunfire.
It was not immediately clear who was responsible for the attack. Boko Haram is not known to operate in the region.
There are fears that Nigeria is becoming increasingly unstable ahead of its delayed general election, pushed back from 14 February to 28 March after the military requested more time to curb the insurgency in the north-east.
The Nigerian Human Rights Commission says at least 58 people have been killed in pre-election violence.
President Goodluck Jonathan, who is seeking re-election, has been strongly criticised for his handling of the Islamist insurgency.
He is facing a strong challenge from opposition leader Muhammadu Buhari, a former military ruler.
Nigeria's electoral commission said on Tuesday it had distributed 75% of voter cards to its 68.8 million voters and said it was on track to reach 100% by the delayed election date.
Dozens of people have been killed in suicide attacks in Nigeria.