Lucas Jackson / Reuters

“All legal restrictions which curtail the civil rights of a single racial group are immediately suspect,” Justice Hugo Black wrote for a majority of the Supreme Court during the waning days of World War II. “Pressing public necessity may sometimes justify the existence of such restrictions; racial antagonism never can.”

With those reassuring words, the Court majority briskly approved the arrest of 110,000 people of Japanese ancestry—a majority of them American-born citizens—and their internment in prison camps far from their homes. “To cast this case into outlines of racial prejudice, without reference to the real military dangers which were presented,” Black wrote, “merely confuses the issue.”

Many contemporary judges have learned the wrong lesson from Black’s disastrous opinion in Korematsu v. United States; they continue to deploy this rhetoric of injured innocence. For example, last year, District Judge William Martini dismissed a lawsuit by a group of Muslim Americans against the New York Police Department. In the years between 2001 and 2011, the department engaged in systematic surveillance of the Muslim community in New York and on the East Coast.

Consider the facts before the court: In 2011 and 2012, the AP revealed the details of a program as focused as the Japanese Internment—a special “Demographics Unit” of the NYPD, set up after 9/11 and managed with the help of an on-loan CIA officer. The unit systematically targeted Muslims of any origin (even “American Black Muslims”), for systematic surveillance—even without any indication of disloyalty or criminal activity. NYPD “rakers” were sent into Muslim communities, student groups, mosques, and businesses to gather background on everyone involved. The target was religion: When investigating the Syrian or Egyptian communities, for example, the units specifically excluded Syrian Jews or Coptic Christians.

NYPD officials denied the existence of the program; but it was hardly secret in the target neighborhoods. Strange men loitered in front of Muslim businesses, and new surveillance cameras appeared, focusing on the entrances to places of worship. As a result, some customers stayed away from the bakeries and butcher shops; attendance fell at the mosques; meetings of student groups thinned out. The chill was felt up and down the East Coast; the unit didn’t limit itself to the five boroughs.

But, Martini said, the police—like the military authorities who locked up the internees during World War II—had nothing against Muslims. They just thought that, because they were Muslims, they might be terrorists. “Plaintiffs have not alleged facts from which it can plausible inferred that they were targeted because of their religion.” No, it was something completely different, he wrote: “the motive for the Program was not solely to discriminate against Muslims, but rather to find Muslim terrorists hiding among ordinary law-abiding Muslims.”

Last week, the U.S. Court of Appeals reversed Martini’s slipshod opinion. The case may end up in front of the Supreme Court; but even if the Court finds a reason to reverse, I will still assign the Third Circuit opinion to my students as a model of how a careful judge analyzes a difficult constitutional claim. (Judge Thomas L. Ambro wrote the opinion for a three-judge panel. Ambro and Judge Julio M. Fuentes are both Clinton appointees, and Judge Jane Richards Roth is a George H.W. Bush appointee.)

The NYPD had prevailed on two main arguments. First, it contended, the program hadn’t hurt the Muslim plaintiffs at all. They weren’t arrested, punished, or denied any “tangible benefit.” But, said the panel, “those not on discrimination’s receiving end can all too easily gloss over the ‘badge of inferiority’ inflicted by unequal treatment itself. Closing our eyes to the real and ascertainable harms of discrimination inevitably leads to morning-after regret.”

Okay, but if there was injury, the department added, the guilty party was the AP, not the NYPD. The AP’s expose won the Pulitzer Prize for investigative reporting in 2012—but if it hadn’t revealed the NYPD’s secret, the plaintiffs wouldn’t have known about it. “In short, [the Department] argues, ‘What you don’t know can’t hurt you,’” the panel explained. “‘And, if you do know, don’t shoot us. Shoot the messenger.’” But that plow won’t scour: “The discrimination itself,” not the revelation of it, “is the legally cognizable injury.” Finally, the city relied on Martini’s reasoning that the program wasn’t aimed at hurting Muslims, but at preventing “Muslim terrorist activities.”

Many lawyers, and some judges, seem to believe that discrimination only counts when it flows from what’s called “invidious motive”—that is, hatred or scorn. Since the cops didn’t hate Muslims, it was okay that they singled them out for surveillance and investigation. The city, said the panel, “wrongly assumes that invidious motive is a necessary element of discriminatory intent. It is not. All you need is that the state actor meant to single out a plaintiff because of the protected characteristic itself ... Thus, even if the NYPD officers were subjectively motivated by a legitimate law-enforcement purpose (no matter how sincere), they’ve intentionally discriminated if they wouldn’t have surveilled Plaintiffs had they not been Muslim.”

This lesson about discrimination is one the nation needs to learn over and over. During the litigation over same-sex marriage, for example, some lawyers (and even some judges) argued that excluding same-sex couples was okay because it wasn’t done out of bigotry—just a desire to keep marriage for heterosexual couples. That, however, is discrimination; hatred isn’t required.

In all equal-protection cases, courts must consider how hurtful and dangerous a specific type of discrimination is. Age, for example, isn’t viewed with sharp disfavor; even brilliant 15-year-olds can be denied a driver’s license. Race and national origin, however, are to be given a hard look—what courts call “strict scrutiny”; sex and a few others get “intermediate scrutiny,” almost as searching.

The Supreme Court has never set a “scrutiny” level for religion; the opinion doesn’t choose between “strict” and “intermediate,” but holds that such discrimination requires some level higher than, say, age. (Judge Roth rather tartly wrote a short concurrence to point out that since sex discrimination gets only “intermediate” scrutiny, maybe religion should too.) “The history of religious discrimination in the United States,” the panel opinion said, “is intertwined with that based on other protected characteristics, including national origin and race.”

All told, the opinion strikes a blow for common sense. There’s no claim that investigation and vigilance are not, and were not, needed; but it should put security forces—local, state, and federal—on notice that compiling lists by religion is not the place to begin. “We have been down similar roads before,” the panel wrote. “Jewish-Americans during the Red Scare, African-Americans during the Civil Rights Movement, and Japanese during World War II are examples that spring readily to mind.” Quoting one of the Japanese exclusion cases, it concluded, “We are left to wonder why we cannot see with foresight what we see so clearly with hindsight—that ‘loyalty is a matter of the heart and mind[,] not race, creed, or color.’”

We want to hear what you think about this article. Submit a letter to the editor or write to letters@theatlantic.com.