CHICAGO — President Obama, delivering a farewell address in the city that launched his political career, declared on Tuesday his continued confidence in the American experiment. But he warned, in the wake of a toxic presidential election, that economic inequity, racism and closed-mindedness threatened to shred the nation’s democratic fabric.

“We weaken those ties when we define some of us as more American than others,” Mr. Obama said, “when we write off the whole system as inevitably corrupt, and when we sit back and blame the leaders we elect without examining our own role in electing them.”

Speaking to a rapturous crowd that recalled the excitement of his path-breaking campaign in 2008, Mr. Obama said he believed even the deepest ideological divides could be bridged. His words were nevertheless etched with frustration — a blunt coda to a remarkable day that laid bare many of the racial crosscurrents in the country.

On Capitol Hill, Senator Jeff Sessions of Alabama presented himself as a moderate in his confirmation hearing for attorney general, while his critics denounced him as a racist. In Charleston, S.C., Dylann S. Roof, the white supremacist who shot nine black churchgoers, was sentenced to death.