* Islamist sect carries out bold attack on northeast city
* Boko Haram biggest security threat in oil exporter
* Western governments concerned about spreading extremism
By Lanre Ola
MAIDUGURI, Nigeria, March 14 (Reuters) - Soldiers fought off Islamist insurgents who attempted to free captured comrades from a military barracks in the northeastern Nigerian city of Maiduguri on Friday, the military said.
Witnesses reported more than two hours of gunfire and explosions, starting at around 7:15 a.m., from the direction of the Giwa barracks, where the army has detained hundreds of Islamist insurgent suspects.
Al Qaeda-linked Boko Haram has killed thousands of people in an almost five-year insurgency aimed at carving out an Islamic state in the religiously diverse country of about 170 million.
"Pockets of terrorists apparently in a move to boost their depleted stock of fighters this morning attacked a military location in Maiduguri with a view to freeing their colleagues who are being held in detention," a military statement said.
It said the attack had been repelled, with heavy casualties among the assailants, while four soldiers had been wounded.
Security experts say the military often exaggerates its own successes and plays down its casualties and those of civilians.
Boko Haram is the biggest security threat in Africa's top oil exporter and the continent's second biggest economy. More than 2,000 people have been killed in Boko Haram violence in the last six months, security sources say.
Human rights groups have said previously that Giwa barracks has been used to illegally detain and torture suspects - allegations denied by the Nigerian military.
The U.N. High Commissioner for Human Rights, Navi Pillay, said in Nigeria on Friday that rights abuses committed by the security forces are increasing support for Boko Haram.
President Goodluck Jonathan intensified a military campaign against the group almost a year ago. Violence in recent months has mostly been confined to rural areas of the poor and undeveloped northeast. An attack in the region's biggest city where there is a heavy army presence is a setback for Jonathan.
Boko Haram has attacked 40 villages this year alone, displacing hundreds of thousands of people, the New York-based Human Rights Watch organisation said in a report on Friday.
Western governments are concerned about Boko Haram joining forces with al Qaeda affiliates operating in the Sahel. The unrest has already pushed tens of thousands of refugees over the borders into neighbouring Niger and Cameroon. (Additional reporting by Isaac Abrak in Kaduna; Writing by Joe Brock; Editing by Alistair Lyon)