HARLINGEN, Tex. — The judge called his next case, scanning the courtroom.

The immigrant who was facing deportation rose to his feet, in a clean T-shirt and khaki pants several sizes too large, with his name — JUAN — printed on a tag around his neck.

But the judge could not see him. Juan’s head did not rise above the court’s wooden benches.

Juan David Gonzalez was 6 years old. He was in the court, which would decide whether to expel him from the country, without a parent — and also without a lawyer.

Immigration courts in this South Texas border town and across the country are confronting an unexpected surge of children, some of them barely school age, who traveled here without parents and were caught as they tried to cross illegally into the United States.

The young people, mostly from Mexico and Central America, ride to the border on the roofs of freight trains or the backs of buses. They cross the Rio Grande on inner tubes, or hike for days through extremes of heat and chill in Arizona deserts. The smallest children, like Juan, are most often brought by smugglers.