From his adopted hometown of Chicago, Obama spoke frankly about the dangers posed by economic inequality, divisiveness and a lack of a "common baseline of facts" in public discourse. He returned again and again to the importance of preserving and upholding democracy.
But in refashioning his winning 2008 campaign message for 2017, he asked the crowd of friends and supporters to hold fast to their optimism and to look within for leadership.
"I am asking you to believe not in my ability to bring about change, but in yours," Obama said. "I am asking you to hold fast to that faith written into our founding documents: ... Yes, we can," he said, voicing the familiar cadence from his first election. "Yes, we did. Yes, we can."
The address was the latest entry in an occasional tradition of outgoing commanders in chief that has produced some of the most memorable speeches in presidential history, including George Washington's farewell and Dwight D. Eisenhower's warning about the rise of the military-industrial complex.
Obama was mindful of the apprehension his followers are feeling ahead of the inauguration of Trump, elected on promises to crack down on immigration, scrutinize Muslims in the U.S. and challenge what he derided as "political correctness."
The president tried to soothe their concerns by noting that a transfer of power is a hallmark of an advanced society.
"I committed to President-Elect Trump that my administration would ensure the smoothest possible transition, just as President Bush did for me," he said. "Because it's up to all of us to make sure our government can help us meet the many challenges we still face."
He acknowledged the moment without dwelling on Trump. Instead, Obama framed such 21st century challenges as growing inequality, terrorism and interconnectivity as part of a profound shift in the global order.
"These forces haven't just tested our security and prosperity, but our democracy as well," he said. "And how we meet these challenges ... will determine our future."
He demanded modern solutions, calling for a "new social compact" that guaranteed education for children, access to unions for workers and a wide safety net.
"If we don't create opportunity for all people, the disaffection and division that has stalled our progress will only sharpen in years to come," he said.
Finally, Obama called for areentry into civic engagement and decried the tendency of Americans to "retreat into our own bubbles."
"We have to try harder; to start with the premise that each of our fellow citizens loves this country just as much as we do; that they value hard work and family like we do; that their children are just as curious and hopeful and worthy of love as our own."
And he warned of democracy's fragility but underscored the unique role of the U.S. as a beacon of freedom.
"Rivals like Russia or China cannot match our influence around the world — unless we give up what we stand for and turn ourselves into just another big country that bullies smaller neighbors."
Obama's final big event was staged as more of a rally than a speech, with Obama striding onto stage to the strains of his campaign anthem, "City of Blinding Lights," and departing with his family to the frenzied applause of 18,000 in attendance.
After he leaves office, Obama plans to take time to "quiet" himself, said Valerie Jarrett, the president's longtime advisor and family friend. He wants Trump to have space to operate and won't comment on relatively small developments, friends say.
He wants to give Trump "room to do his homework," Jarrett said.
Yet Obama also wants to keep an open line of communication with Trump, who aides think may want to consult with him as the last person to do the job. Since Trump was elected, Obama has abandoned his campaign season criticism of Trump and focused publicly on the importance of a smooth transition.
Still, if something troubles him, he has told friends, he may speak out. On Tuesday night, he demonstrated for the world — and, perhaps for Trump — that he can still command the attention of the American public. He is leaving office with high favorable ratings and, perhaps just as important, has honed his ability to connect with the voters of the Obama coalition.
Obama called on white Americans to remember that the effects of slavery and Jim Crow didn't suddenly vanish with the social advancements of the 1960s, "that when minority groups voice discontent, they're not just engaging in reverse racism or practicing political correctness."
Conversely, he said, blacks and other minorities must think about the middle-aged white man whose world has been upended by economic, cultural and technological change.
"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.
Throughout his presidency, Obama has used his bully pulpit to inspire, condemn and cajole. He was always heavily involved in writing his biggest speeches, and his team of young speechwriters spent as much time with him as did more senior staff.
Chicago writers have always been at the heart of his craft. His earliest message guru was Chicago political mastermind
"This is where I learned that change only happens when ordinary people get involved, get engaged, and come together to demand it," Obama said of his hometown. "After eight years as your president, I still believe that."
Each time Obama mentioned his departure from the White House, the crowd voiced its objection, especially as he began to signal the end of his speech. At the end, he singled out his wife, Michelle, for being his best friend and role model. She was dry-eyed, but daughter Malia teared up during the tribute.
The loudest cheers were for Vice President
Some parts of the Obama coalition were not yet ready to follow that lead. When a protester began to shout during Obama's speech, the crowd rose up to drown her out, in what may have been the loudest chants of the night.
"Four more years!" they shouted. "Four more years!"
Watch the full speech below:
Parsons reported from Chicago and Memoli from Washington.
8:35 p.m.: This story was updated with more of Obama's remarks.
6:35 p.m.: This story was updated with Obama's remarks.
4:05 p.m.: This story was updated with excerpts from Obama's prepared remarks.