Nigerian officials had said Cameroon was threatening to force the repatriation. Cameroon previously has dumped thousands on the border.
Nigerian emergency agency spokesman Sani Datti says Sunday that an agreement for their return “voluntarily and in a dignified manner” has been signed by the UNHCR refugee agency, Nigeria and Cameroon.
Last month, Nigerians who had returned home were blocked from returning to Cameroon though they complained they did not have enough water as temperatures soared over 100 degrees (42 degrees Celsius).
A new influx will tax Nigerian officials struggling to cater for 2.1 million people displaced within the country. The U.N. says another 600,000 are displaced in the region.