What a difference a lawyer makes.

According to a new analysis of nearly 102,000 cases of detained undocumented, unaccompanied minors going back a decade and through the end of June, fewer than half had legal help during the immigration hearing on whether they met the criteria to be allowed to stay in the United States (more on that criteria in a moment).

Of those who had lawyers, and whose cases have closed, almost half won permission to stay. Of those standing alone, with no legal help to make their case, 9 out of 10 were deported.

The analysis was done by the nonpartisan Transactional Records Access Clearinghouse at Syracuse University, which obtains large data blocks from the federal government on immigration, drug enforcement, the Internal Revenue Service and other government policies and agencies. Under its Immigration Project, TRAC charts the recent surge in detentions along the Mexican border and counts an overall backlog of nearly 42,000 cases — a backlog that is growing.

In fact, since this surge began in 2011, there have been more than 52,000 new cases, of which more than 38,000 — or 73% — are still pending.

TRAC’s analysis of hearing outcomes for those with lawyers and those without makes a pretty compelling case that these detained kids should have attorneys at their elbows. The argument here isn’t that all the kids should be allowed to stay but that immigration law creates clear categories in which children from other countries can gain permission to live in the U.S. legally. Judging by this analysis, it’s pretty clear we’re going to be kicking out a lot of minors who have cause to stay.

So what are the criteria? It’s a confusing and mixed bag of options. Immigration law allows granting asylum status to minors who have a legitimate fear of persecution based on race, gender or other defined classes (generic fear of violence doesn’t clear the hurdle). It also can grant Special Immigrant Juvenile status to kids who have been abandoned, abused or neglected (that involves a finding first by a civil court), special U or T visas for victims of crime (usually by U.S. officials) or human trafficking. Minors also might qualify under the Violence Against Women Act if they were victims of domestic abuse. And in some cases, permission to stay is granted to further family reunification.

It’s a complicated system, and in a society that embraces the concept of due process, it is inherently unfair — and contrary to our standards — to force minors to try to parse these byzantine immigration laws on their own. If they have a right to stay, it is incumbent on us to ensure that that right is observed.

The Times editorial page has argued that unaccompanied minors should have lawyers. Most of the lawyers now working with the kids are pro bono through organizations such as Kids In Need of Defense and the Florence Immigrant and Refugee Rights Project. The new justice Americorps will help some, but that’s limited to 100 volunteer lawyers. The American Civil Liberties Union and other immigrant rights groups have sued the federal government over the issue, and hope to get a judge to order the government to provide lawyers, similar to public defenders provided to indigent defendants in criminal proceedings.

The legal argument is uncertain, but the moral argument is pretty strong. Kids in crisis, and at real risk, deserve our help. The Obama administration hasn’t gone this far yet, but the United Nations High Commissioner for Refugees views the flow of kids out of Central America as an international refugee crisis. It’s time we did so as well.

But until then, the least we can do is give the kids a chance to make their best argument.

Follow Scott Martelle on Twitter @smartelle