At least 9,000 people have fled violence in northern Nigeria and crossed into neighbouring countries as a government offensive aims to end a four-year Islamist insurgency, the UN said on Tuesday.

In addition to those refugees, a local official in northeastern Nigeria, where the violence has been concentrated, has said some 19,000 wheat and rice farmers have been chased away from fields, raising concerns over potential food shortages.

The United Nations said aid workers had found more than 3,000 people along the border inside Cameroon, which neighbours northeastern Nigeria, where the violence has been concentrated.

The number of those who have fled to neighbouring Niger was recently put at more than 6,000.

"Most of those who have arrived so far are women and children," Adrian Edwards, spokesman for the UN high commissioner for refugees, told reporters in Geneva of the refugees in Cameroon.

"They are being hosted in churches and schools, and relying on food from the churches and local population,"

Those who have fled to Niger include Nigerians as well as citizens of Niger and Chad, Edwards said. The UN refugee agency has sent an aid convoy to the area of Niger where the refugees are located.

The Nigerian government imposed a state of emergency in three northeastern states in May and launched an offensive in an effort to crush the insurgency by Islamist extremist group Boko Haram.

The UN human rights office has in the past sounded the alarm over the impact of the conflict on civilians, who have fallen victim to abuses by both the insurgents and the military.

In the latest attack on Sunday, insurgents opened fire at a secondary school and a military checkpoint, sparking a five-hour shootout in the northeastern city of Damaturu.

Eleven people were killed in the violence, according to the military, including seven students, two teachers and two insurgents.

Details of the offensive have been sketchy since it was launched on May 15, with the military having cut phone service in much of the region as part of its strategy. Access to remote areas where many operations are occurring is also limited.

The military has claimed successes and Islamist attacks appear to have declined in recent weeks, but questions have been raised over whether the gains will be only temporary.

Boko Haram leader Abubakar Shekau has distributed a video message claiming soldiers have retreated and been killed by the insurgents. The video purported to show weapons and vehicles seized from soldiers.

The military dismissed his claims as propaganda.

The insurgency has left some 3,600 people dead since 2009, including killings by the security services, who have come under major criticism over alleged abuses.