In his final speech to the nation as the 44th president of the United States, Barack Hussein Obama offered a strong defense of American democracy and pluralism, telling the nation that its form of government relies on goodwill and tolerance.

“Our Constitution is a remarkable, beautiful gift,” Obama said. “But it’s really just a piece of parchment. It has no power on its own. We, the people, give it power—with our participation, and the choices we make. Whether or not we stand up for our freedoms. Whether or not we respect and enforce the rule of law.  America is no fragile thing. But the gains of our long journey to freedom are not assured.”

Speaking at McCormick Place in Chicago—just a couple miles south of Grant Park, where he first spoke to the nation as president-elect in November 2008—the president outlined his major accomplishments and thanked voters, his family, and his staff. But Obama also outlined what he saw as a three-pronged threat to American democracy, in a speech that could only be heard as a detailed rebuke of Donald Trump, the man who will replace him in the White House in 10 days’ time.

Obama has always enjoyed playing the role of social theorist, and he took one last opportunity to expound his theory from the bully pulpit. The litany of locations and events he mentioned mapped out his vision of a United States where people of color, women, and gay and lesbian Americans are not simply included but are indeed integral to the identity of the nation—from the founding to Western expansion, the Underground Railroad to “immigrants and refugees” who came across the sea and, pointedly, the Rio Grande, suffragettes to labor organizers, activists who fought for the civil rights of African Americans and LGBT Americans alike, and soldiers from Omaha Beach to Afghanistan.

“That’s what we mean when we say America is exceptional,” Obama said, perhaps settling a score with the critics who once claimed he did not believe in the idea, “not that our nation has been flawless from the start, but that we have shown the capacity to change, and make life better for those who follow.”

Yet the nation is fraying, he cautioned. The president argued that the start of the 21st century, from 9/11 attacks to the Great Recession, and implicitly in Trump’s election, had threatened to “rupture [the] solidarity” on which the country rests. The threat came from three corners, he said: unequal economic opportunity; racism and discrimination; and the retreat into bubbles of likeminded individuals.

He warned that indulging fear would endanger a society ordered by Enlightenment ideals of reason, tolerance, and justice. “That order is now being challenged—first by violent fanatics who claim to speak for Islam; more recently by autocrats in foreign capitals who see free markets, open democracies, and civil society itself as a threat to their power,” Obama said. “The peril each poses to our democracy is more far-reaching than a car bomb or a missile.” He asked the nation to come together in the work of rebuilding American democracy.

But it is not just external threats such as these that pose a danger, he said—so does the temptation to shut out those with different outlooks. “For too many of us, it’s become safer to retreat into our own bubbles, whether in our neighborhoods or college campuses or places of worship or our social media feeds, surrounded by people who look like us and share the same political outlook and never challenge our assumptions,” Obama said, connecting it to the advent of a media that is not only partisan but riddled with misstatements of fact—and a surfeit of maliciously false news. “We become so secure in our bubbles that we accept only information, whether true or not, that fits our opinions, instead of basing our opinions on the evidence that’s out there.”

Obama’s decision to deliver the farewell address before a crowd of adoring supporters represented a continuation of the style in which he campaigned, and the style he has preferred to govern. While most presidents have delivered their final speeches on camera from the White House, Obama has always disliked the Oval Office address, preferring to speak at a lectern in the East Room when he had to, and speak live before a crowd when he could, feeding from its energy.

Most farewell speeches also do not loom large in history. While outgoing presidents may hope that the addresses offer them a chance to shape and solidify their legacies, few are remembered after the fact—perhaps really only two: George Washington’s in 1796, and Dwight Eisenhower’s in 1961, in which he coined the term “the military-industrial complex.”

Obama’s farewell address was, like many of his major speeches, a finely crafted one; he is one of the finest orators and writers to occupy the office. But despite its emphasis on the ideals of the nation going back to the founding, it seemed inexorably linked to the present moment in American history. The speech seemed like a lecture for Trump on what makes America great and a pep talk for Obama’s supporters on the importance of keeping the faith.

“You were the change. You answered people’s hopes,” Obama said, recalling the two buzzwords of his first run for president. But he added: “Our progress has been uneven. The work of democracy has always been hard. It’s always been contentious. For every two steps forward, It often feels we take one step back.”

Obama didn’t have to mention Trump’s name for it to be clear to all who he was referring to. Nearly every paragraph in this speech seems to have a line that directly or indirectly answered Trump. He said that American “potential will only be realized if our democracy works. Only if our politics reflects the decency of the our people.” In a quasi-Marxist rejection of race in favor of class, he rejected the nativist claims of the Trump campaign, saying, “If every economic issue is framed as a struggle between a hardworking white middle class and undeserving minorities, then workers of all shades will be left fighting for scraps while the wealthy withdraw further into their private enclaves.” He warned that depriving children of immigrants would only backfire as they came to represent a larger portion of the workforce. The ties of society weaken, he said, “when we define some of us as more American than others; when we write off the whole system as inevitably corrupt, and blame the leaders we elect without examining our own role in electing them.”

In what might have seemed improbable only a few a years ago, one of his biggest applause lines came in a simple restatement of the First Amendment principle of freedom of religion: “That’s why I reject discrimination against Muslim Americans.” On climate change, Obama warned Trump and other deniers, “Reality has a way of catching up with you.”

But Obama was not ready to let his own backers off the hook to slip into disconsolation. He called on them to engage with their fellow citizens, saying that while their faith would sometimes be disappointed, it would overall be affirmed. Early in his speech, he hailed the impending peaceful transfer of power to Trump, and scolded members of the crowd who booed or groaned.

As for the president, he was able to keep his composure through most of the speech. It was only in the last minutes of the address, as he thanked the first lady, his daughters, Vice President Joe Biden, and his staff, that the president’s face began to twitch, and he finally had to wipe away a tear. It seemed fitting that the emotional climax of the speech would come at that time—the president’s personal story, his confident and cheerful demeanor, have always been his strongest political asset. Even as his policy legacy teeters on the precipice of destruction, the president remains personally popular, and his decency and family remain widely admired.

And then Obama offered one more callback to his historic 2008 campaign. “Yes we can,” he said. “Yes we did.” And then, once more for the future: “Yes we can.” But will we? At a time when many Americans of all views are more dubious than ever about that proposition, and despite his dire warnings minutes earlier, Obama seemed just as stunningly, serenely confident as he had eight years ago.

“That faith I placed all those years ago, not far from here, in the power of ordinary Americans to bring about change—that faith has been rewarded in ways I couldn’t possibly have imagined,” he said. “I hope yours has, too.”