The worst thing about opposing President Trump is sometimes he's right.

And the troubling fact is that Trump's instincts, if not his incompetently executed and deliberately cruel attempted solutions, are often right on immigration. That includes the instinct behind his angry remarks to reporters on Tuesday: "We have the worst laws of any country in the world. ... You have to fix the asylum situation, it's ridiculous."

Indeed, it is ridiculous. As The New York Times explains in a deeply reported front-page story headlined "The U.S. immigration system may have reached a breaking point," it is also tragic, with nearly 100,000 migrants arriving on the southern border every month, hoping to be admitted to the country.

The migrants know that if they bring a child with them, current U.S. law will forbid them from being held in custody for longer than 20 days. (It was an attempt to skirt this stricture that led the Trump administration to implement its rightly decried policy of separating adults and children at the border.) The migrants also know that if they say they're seeking asylum and can pass a screening to determine if they have a "credible fear" of persecution in their home country, current law will grant them a hearing before an immigration court. What they may not know but will soon find out is that the backlog means that this appearance before a judge will not take place for years. (Those arriving today likely won't have a formal hearing until 2021.)

In the meantime, most will be released on their own recognizance, expected to appear before a judge when summoned. But many won't, opting instead to disappear into a vast country, taking advantage of lax enforcement of laws against hiring undocumented immigrants to make lives for themselves while remaining under constant threat of deportation if they get caught by Immigration and Customs Enforcement (ICE).

It's a mess. But things truly cross over into the absurd with the recent decision of a California judge to block the Trump administration's effort to get most migrants to remain in Mexico until their asylum hearing. The U.S. is confronting a flood of migrants fleeing oppression, violence, and poverty in one country (usually Honduras, Guatemala, or El Salvador), crossing a massive intermediary country (Mexico) that no one claims is persecuting them, and yet a judge insists that it's a violation of the law to deny them entry.

That ruling is either an outrageous warping of the law, in which case it needs to be quickly overturned by a higher court, or it is a demonstration that the law itself needs to be changed to allow U.S. policymakers to determine who and how many get admitted to the country, and when. In the current situation of years-long backlogs and restrictions on detaining kids, it amounts to a wide-open door to anyone who shows up on the border with a child claiming asylum. To the extent that current law requires this fiasco, it needs to be scrapped and replaced.

And it's Democrats who will need to take the lead in doing so.

Trump may be right to highlight the problem, but his own efforts to respond to it are at every step motivated by racism and bad faith (his real goal is to end all immigration from countries to our south). The combination of his xenophobic malice with outright ineptitude leads those efforts to backfire in multiple ways, making a bad situation vastly worse. His polarizing insistence on building a wall along the border would do nothing to improve the situation, since most arrivals are showing up at official entry points. His government shutdown over funding the wall led immigration judges to be furloughed, which only increased the backlog on asylum claims. His attempt to cut foreign aid to the migrants' countries of origins will likely increase the number of people heading north. His threats to close the southern border entirely have produced a spike in those seeking asylum. And his repeated denigration of Mexicans has made the government of Mexico reluctant to collaborate with efforts to address the problem.

That's why a solution will need to come from the left, even though it will cut against the shift in Democratic public opinion over the past decade in the direction of greater immigration liberalization.

Since the years following World War II, countries have had to balance the principles of national sovereignty and self-government against the moral demands of humanitarian universalism and international law. The ruling of the California judge is the latest sign that in the United States the proper balance has been lost, with domestic law tilting too heavily in the direction of universalistic considerations. The nation on our southern border is not persecuting anyone. If the U.S. lacks the power to dictate that migrants from third-party countries wait for their asylum hearings on the far side of that frontier, then the U.S. lacks the power to determine who will and who will not be allowed in — which means the U.S. lacks a meaningful border. And as Trump himself memorably put it in what is arguably the truest statement he ever uttered: "A country without borders is not a country at all."

Interestingly, the 2020 presidential candidate who appears to grasp this point with the least ambivalence is also the candidate furthest to the left. Asked last Sunday at an Iowa town hall if he's an advocate of open borders, Bernie Sanders pushed back hard:

I'm afraid you may be getting your information wrong. That's not my view. What we need is comprehensive immigration reform. If you open the borders, my God, there's a lot of poverty in this world, and you're going to have people from all over the world. And I don't think that's something that we can do at this point. Can't do it. So that is not my position. [Politico]

Sanders didn't elaborate on why he would consider this a problem, but the reason why a social democrat would oppose letting all comers into the United States is obvious — because the generous social-welfare system Sanders wants to enact would be extraordinarily expensive, and in a world of finite resources limits need to be set. And the most reasonable limit is the elemental political distinction — the one that separates citizens from non-citizens, residents from non-residents, Americans from non-Americans.

Socialism in one country might be a pipe dream, but it's nothing compared with a fantasy of socialism, or really any kind of advanced welfare state, for (potentially) everyone on the planet.

The immigration system has reached a breaking point. Repairing it will require many steps — including more money for immigration courts and judges to speed up the hearing process, better forms of tracking asylum-claimants released into the country while awaiting review, and the reaffirmation of the legitimacy of keeping migrants on the far side of the border while they await word on their applications for asylum.

The dueling imperatives of self-government and humanitarianism demand nothing less.