Maimta Modu, 62, had come to a displaced-persons camp with other residents of his tiny village, and now they have to pay soldiers a fee to be escorted back periodically to check on their crops. If he returns on his own, he said in a reference to Boko Haram, “those boys will slaughter me.”

President Muhammadu Buhari has repeatedly declared the war with Boko Haram over. The military has chased the insurgents from hiding places in the forest. But the radical Islamist terrorist group is still waging deadly attacks across the countryside. And in some camps for displaced people, new arrivals fleeing the militants are moving in even as others are moving back home.

Caught in the middle are people like Idi Hassan and his wife, who were in the convoy with six of their young children in his truck bed. The Hassans had been living for two years in the squalid camp in Maiduguri, relying on food handouts and eager to get back to their farm north of here, where they hoped to make a living.

“The area has been liberated, and we’re going home,” Mr. Hassan said, sitting behind the wheel as his wife breast-fed their infant in the passenger’s seat.

Yet insurgents still roam the northeast and frequently crisscross roads like the one that was taking Mr. Hassan and his family home. Just weeks ago, Boko Haram ambushed soldiers along this very highway, killing seven of them.