At first glance, it would seem easy to explain the election as part of a 2024 global wave against incumbents beset by post-COVID turmoil and inflation. Britain saw a huge Tory parliamentary majority turn into its thinnest minority in the party’s nearly 200 year history. Germany’s governing coalition has collapsed amid soaring unpopularity. French President Emmanuel Macron’s party was crushed in parliamentary elections. In Japan, the ruling Liberal Democratic Party lost its parliamentary majority. So it might seem preordained that Kamala Harris, representing the incumbent administration, lost decisively as well.

But Harris could have bucked the trend. The American economy is doing better than those of other nations. Employment is strong, wages are up, inflation is down, productivity is soaring. More importantly, Donald Trump has many strengths as a political figure, but he has many weaknesses. Recall that after Jan. 6, 2021, Trump’s approval rating was down to 34% in a CNN poll. Then came the overturning of Roe v. Wade and the 2022 midterms, in which the Republicans did very badly and MAGA candidates in particular got crushed. Trump’s favorable rating sank to 31% in a CNN poll, with an unfavorable rating at a staggering 60%. Republicans were disillusioned with him. Trump was leading a Republican Party that had lost its House majority in 2018, its Senate majority and the presidency in the 2020 cycle, and then fared historically badly in those 2022 midterms.

But Democrats blew it. The New York Times estimates that Harris will lose the national popular vote — a first for Democrats since 2004 — by about a point and a half.

Global inflation is something that was hard to shut down, but there were other issues Democrats flubbed, which inflamed the opposition and depressed their base. I should say that I noted each of these mistakes at the time, often provoking angry responses from the left.

The first big error was the Biden administration’s blindness to the collapse of the immigration system and the chaos at the border. An asylum system that was meant for a small number of persecuted individuals was being used by millions to gain illegal entry. Instead of shutting it down, liberals branded anyone protesting as heartless and racist. They missed a massive shift in American public opinion. In 2020, the percentage of Americans who wanted to decrease immigration was 28%; by this year, it was 55%. When Harris went on “The View” and was asked how she would have differed from Biden, instead of basically saying she wouldn’t have done anything differently, she should have said, “I would have shut down the border early and hard.”

The second error was the overzealous misuse of law to punish Trump. The most egregious of the prosecutions pursued was District Attorney Alvin Bragg’s hush money case in New York, one that even he was once skeptical of but was reportedly pressured by some on the left into pursuing. Some, including the Georgia election interference case, were legitimate. But the host of them piled on in rapid succession gave the impression that the legal system was being weaponized to get Trump. The indictments confirmed to his base what it had always believed — that overeducated urban liberals were hypocrites, happy to bend rules and norms when it suited their purposes. (It’s worth noting that in this week’s election, a CNN exit poll found that among those who believed that U.S. democracy is threatened, a majority supported Trump.) As Trump’s list of indictments grew, his campaign contributions increased and his poll numbers solidified.

The final error is a more diffuse one: the dominance of identity politics on the left, which made Democrats push for all kinds of diversity, equity and inclusion policies that largely came out of the urban, academic bubble but alienated many mainstream voters. There is an irony in claiming to be pro-Latino by insisting that people use the term “Latinx,” only to discover that Latinos themselves think the word is weird. This kind of obsession made Democrats view people too much through their ethnic or racial or gender identity, and it made them miss, for example, that working-class Latinos were moving toward Trump perhaps because they were socially conservative or liked his macho rhetoric or even agreed with his hard-line stance on immigration. One of Trump’s most effective ads, on trans issues, ended with the tagline: “Kamala is for they/them; President Trump is for you.”

The problem is much deeper than nouns and pronouns. The entire focus on identity has morphed into something deeply illiberal: judging people by the color of their skin rather than the content of their character. Similarly, university speech codes and cancel culture have become ways that the left has censored or restricted that most cherished of liberal ideas, freedom of speech.

One simple way to think about the lessons of this election is that liberals cannot achieve liberal goals — however virtuous — by illiberal means.