A Nigerien soldier and three Boko Haram gunmen died in an attack by the Nigerian jihadist group targeting a prison in Niger early on Sunday, media reports said.

Nigerian officials said the Boko Haram gunmen armed with grenades and assault rifles attacked a civil prison in southern Nigerien city of Diffa, reported Press TV. At least two Nigerien soldiers were also wounded in the shooting that lasted for at least an hour.

"Three of the assailants and one soldier were killed before the attack was repelled," Nigerian military sources said, according to Reuters. "When the attack was repelled, the assailants fled, probably back into the town. We are searching for them."

The militants were trying to free some Boko Haram members held in the prison, reported AFP. It is second attack on Diffa prison this year as Boko Haram militants launched a similar attack on the same facility in February.  

A Boko Haram suicide male bomber, disguised as a woman in a full-face veil or burqa, killed 15 people in Chad's capital N'Djamena on Saturday. Nigeria, Niger, Chad and Cameroon formed a coalition in February to drive Boko Haram militants from captured territories.  

Boko Haram recently pledged allegiance to Islamic State group and announced its new name "Islamic State's West Africa Province," according to the Associated Press. 

The Nigerian militant group has recently stepped up its attacks in the Muslim fasting month of Ramadan, HNGN reported previously.

Nigeria's President Muhammadu Buhari has vowed to defeat the terror group but analysts believed he can't do much alone. "The fight against Boko Haram is unlikely to be concluded with any rapidity. The fact remains that while Boko Haram continues to be defined as a Nigerian problem, evidence suggests that it has become a quandary of regional proportions requiring a regional solution," said Ryan Cummings, chief Africa analyst with the Red24 consulting group, according to AFP.