Some 480 Nigerian soldiers have crossed into Cameroon following fierce fighting with Boko Haram militants.
Reports claimed that the troops had joined thousands of citizens fleeing the fighting, but Nigeria said they were conducting a "tactical manoeuvre".
Clashes are said to be continuing in the border town of Gamboru Ngala.
Boko Haram on Sunday released a video claiming that it had established an Islamic state in the towns and villages it controls in north-eastern Nigeria.
The group's five-year insurgency has intensified in recent months despite the deployment of thousands of extra troops to the worst-affected areas.
Last week, a group of soldiers refused to follow orders to go and fight Boko Haram, saying the militants were better equipped.
Insurgents also seized one of Nigeria's two main police training academies, which is near the town of Gwoza, captured earlier this month.
The Nigerian soldiers were accommodated in the Cameroonian town of Maroua, about 80km (50 miles) from the Nigerian border, Cameroon army spokesman Lt Col Didier Badjek told the BBC.
The Nigerian defence ministry said in a statement that the soldiers found themselves "charging through the borders in a tactical manoeuvre" after a sustained battle.
The statement said it was standard practice for them to hand over their weapons and the soldiers are now returning home.
Thousands of civilians are also said to have fled across the border.
Cameroon has officially closed its 1,600 km border with Nigeria to help contain the spread of the deadly Ebola virus.
But correspondents say this is impossible to enforce in remote areas near the fighting.
Analysis: Tomi Oladipo, BBC News, Lagos
Nigeria will be keen to stress that its soldiers were not deserting, contrary to the initial Cameroonian account, when they crossed the border, to avoid fuelling the idea that the Nigerian army is weaker than the Boko Haram militants.
The question still remains whether the continuing violence in north-east Nigeria is a result of the failures of the Nigerian military as opposed to the strength of Boko Haram, considering there have been glaring problems in the equipping and deploying soldiers on the frontline.
There have been reports of mutinies within the army ranks and recently soldiers' wives protested at the deployment of their husbands, saying they were ill-equipped to fight the insurgents.
The Nigerian military has insisted its forces are up to the task but the fact that Boko Haram has been able to keep hold of Gwoza for some weeks now means residents of towns and villages across the north-east fear they could be next.
Boko Haram launched an attack on the police station and a military base in Gamboru Ngala at 05:30 local time (04:30 GMT), the AFP news agency reports.
In May, some 300 people were killed in an attack which left much of the town in ruins.
It is near Gwoza, the largest town under control of Boko Haram. In the most recent census, in 2006, it had a population of more than 265,000 people.
In the 52-minute video released on Sunday, Boko Haram leader Abubakar Shekau said Gwoza was now "part of the Islamic state".
He did not specify whether his group now had any links to the Islamic State (IS) group, which has seized much of northern Iraq in recent months, prompting the US to respond with air strikes.
There is no evidence for such links but in July, Mr Shekau congratulated IS on its territorial gains.
Who are Boko Haram?
- Founded in 2002
- Initially focused on opposing Western education - Boko Haram means "Western education is forbidden" in the Hausa language
- Launched military operations in 2009 to create an Islamic state
- Thousands killed, mostly in north-eastern Nigeria - but also attacks on police and UN headquarters in capital, Abuja
- Some three million people affected
- Declared terrorist group by US in 2013
Boko Haram controls several areas, mostly in Borno state where the group was launched, but also in neighbouring Yobe state.
Nigeria's military spokesman Chris Olukolade responded with a statement dismissing the declaration of an Islamic state as "empty".
The video also shows about 20 men in civilian clothes apparently being shot dead.
The BBC's Nathalie Wakam in Cameroon says the situation is worrying for the country's officials, who have called on the international community to help them tackle the threat from Boko Haram.
China, France, the US and UK all sent some military assistance - advisors and help with intelligence - to Nigeria after some 200 schoolgirls were seized from Chibok, near Gwoza, in April.