AGADEZ, Niger — Behind high metal gates at the edge of town, the migrants wait their turn, not daring to leave their mud-brick compounds — the final staging post before the perilous trip across the Sahara and the sea beyond. Even neighborhood children know where they are hiding.

The migrants already bear the wounds and scars of the arduous trip, pulling up the legs of their trousers to show where they had been kicked and beaten by the police, all along the line, from Senegal to Mali to Burkina Faso to Niger.

Now they have placed their lives in the hands of local “connections men,” smugglers who arrange the next leg of the dangerous passage, all the way to the Mediterranean Sea.

“I know all the tricks, how it works, from Agadez to Libya,” said a man in a brown polo shirt, speaking on the condition that only his first name, Mahamadou, be used. “When I see that people have the courage to cross the sea, I help them. That’s how I earn my living.”