Some waved off this seeming contradiction, saying Mr. Trump’s other harsh immigration policies put his administration’s actions in a different context. And it is true that even when using similar tactics, President Trump and President Obama have expressed very different attitudes toward immigration and espoused different goals.

Those arguments underscore the degree to which this controversy is animated as much by attitudes toward the president and the way he has made immigration a focus of partisan conflict as by specific policy preferences.

Deadlock over immigration has meant that, for decades, politicians have turned to the same compromise: greater enforcement of immigration laws in exchange for more liberal policies. The Reagan administration’s amnesty for millions of undocumented immigrants, for instance, also increased security along the Mexican border and made it harder for undocumented immigrants to work. The Obama administration sharply increased deportations in his first term in the hope of building a case for comprehensive immigration reform. (That move did not pay off.)

Detained immigrant children have frequently been caught up in the enforcement side of that bargain. U.S. Immigration and Customs Enforcement and the Immigration and Naturalization Service before it have argued that immigration detention is an essential part of enforcement and deterrence, and have vigorously pursued detention of families and children throughout multiple presidential administrations.

Immigrants’ rights activists have brought a series of lawsuits that challenged and ultimately overturned many detention efforts. But those efforts did not reach the level of national scandal that the Trump administration’s policies have now.

So what has changed? Rising partisan polarization.

Long-running social science surveys have found that since the 1980s, Republicans’ opinions of Democrats and Democrats’ opinions of Republicans have been increasingly negative. At the same time, as Lilliana Mason, a political scientist at the University of Maryland, writes in a new book, partisan identity has become an umbrella for other important identities, including those involving race, religion, geography and even educational background. It has become a tribal identity itself, not merely a matter of policy preferences.

So it’s not that liberals didn’t care about immigrant children until Mr. Trump became president, or that they’re only pretending to care now so as to score political points. Rather, with the Trump administration’s making opposition to immigrants a signature issue, the topic has become salient to partisan conflict in a way it wasn’t before.