* Insecurity plagues Nigeria a month before elections
* Militants still control northeastern town of Baga
* Several Boko Haram fighters killed, military HQ says (Adds witness accounts, Nigeria military comment, details)
By Lanre Ola
MAIDUGURI, Jan 14 (Reuters) - Nigerian security forces repelled an attack by Islamist rebels on the northeastern town of Biu on Wednesday, killing several of the insurgents, witnesses and the military said.
Several dozen fighters belonging to the Boko Haram militant group drove into Biu in pick-up trucks and on motorcycles, witness Yahaya Mshelliza told Reuters by telephone.
"They came shouting 'Allahu Akbar' (God is greatest) and shooting everywhere, but confronted by the soldiers for three hours, most them were killed," Mshelliza said.
"At the moment only three escaped into the bush and are being pursued by the soldiers."
Growing insecurity linked to Islamist militants is a major issue for President Goodluck Jonathan a month before polls in which he faces a rival, Muhammadu Buhari, who was seen as tough on security when he was a military ruler in the 1980s.
Nigeria's military headquarters, which rarely comments on attacks, confirmed the incident on its Twitter account.
It was the second attack on a major town by Boko Haram militants in the past two weeks.
"Terrorist attack repelled by the military in Biu," the military tweeted. "Troops in pursuit of fleeing terrorists."
It said that five Boko Haram fighers had been captured as well as two anti-aircraft guns.
Witness Mohammadu Idi said he saw at least 17 bodies of Boko Haram fighters "littered on the road" near the Biu army barracks after the attack.
The group's fighters seized the military base and town of Baga, on the shores of Lake Chad, on Jan. 3. Baga was the headquarters of a multinational force with troops from Chad, Niger and Cameroon. The militants have killed scores and razed dozens of homes there, with the military putting the death toll at 150, while some local officials have put it as high as 2,000.
The rebels remain in control of Baga, which Nigerian forces backed by air power have tried so far unsuccessfully to retake.
"The military has not given up on Baga or any part of the country," it said on its Twitter feed late on Tuesday.
The United States said on Tuesday it sees the Feb. 14 election in Nigeria, Africa's biggest economy, as a factor behind the sharp rise in attacks by Boko Haram, a group which has killed thousands since launching an uprising five years ago.
On Tuesday, a suicide bomber blew himself up outside a mosque in the northeastern city of Gombe, killing at least two other people and wounding 14 during prayers. (Additional reporting by Isaac Abrak in Abuja and Ardo Abdullah in Bauchi; Writing by Tim Cocks; Editing by Louise Ireland)