NOGALES, Ariz. — In a 120,000-square-foot warehouse on the edge of this desert city, Border Patrol agents line up hundreds of children who may have never seen a doctor for basic vaccinations and other medical care, hand out snacks or join them for a game of basketball under a circuslike tent that doubles as a recreation room.

In a makeshift processing center, the children — all minors caught crossing the border in the Rio Grande Valley of Texas without parents — are housed for as many as three days or more in nine holding pens. Boys are separated from girls and older children from younger ones; teenage mothers and their babies stay in a cell of their own.

There is barely room to walk; mattresses line the concrete floor, which also has long bleachers bolted to it. The children are being transferred here from Texas because a similar site there cannot take any more.

Customs and Border Protection officials said Wednesday that 900 children from Guatemala, El Salvador and Honduras were being held here — the newest arrivals still in the clothes they wore on their trek to the United States, the others clad in white T-shirts and blue shorts, as in a reformatory. On one mattress, a girl barely in her teens wept, her face buried in a soiled stuffed lamb. Nearby, a toddler smiled as she held the hand of a Border Patrol agent taking her for a walk.