With a final shout of his campaign mantra “Yes We Can,” President Barack Obama on Tuesday urged Americans to stand up for US values and reject discrimination as the country transitions to the presidency of Republican Donald Trump.

In an emotional speech in which he thanked his family and declared his time as president the honor of his life, Obama gently prodded the public to embrace his vision of progress while repudiating some of the policies that Trump promoted during his campaign for the White House.

“So just as we, as citizens, must remain vigilant against external aggression, we must guard against a weakening of the values that make us who we are,” Obama told a crowd of 18,000 in his hometown of Chicago, where he celebrated his historic 2008 election as the first black US president.

Trump, who takes office on January 20, proposed that the United States temporarily ban Muslims from entering the country, build a wall on the border with Mexico, upend a global deal to fight climate change and dismantle Obama's healthcare reform law.

Obama made clear his opposition to those positions during fiery campaign speeches for 2016 Democratic presidential nominee Hillary Clinton, but he has struck a more conciliatory tone with Trump since the election. In his farewell speech, he made clear his positions had not changed.

“I reject discrimination against Muslim Americans,” he said in a clear reference to Trump, drawing applause.

“If anyone can put together a plan that is demonstrably better than the improvements we've made to our health care system, that covers as many people at less cost, I will publicly support it,” he said in another prodding challenge to his successor.

Trump has urged the Republican-controlled Congress to repeal the law right away.

AN UNREALISTIC VISION

Obama, who came to office amid high expectations that his election would heal historic racial divides, acknowledged that was an impossible goal.

“After my election, there was talk of a post-racial America,” he said. “Such a vision, however well-intended, was never realistic. Race remains a potent and often divisive force in our society.”

But the president said he remained hopeful about the work that a younger generation would do. “Yes we can,” he said. “Yes we did.”

First Lady Michelle Obama, Vice President Joe Biden, his wife Jill Biden, and many current and former White House staff members and campaign workers attended the speech. Obama wiped his eyes as he addressed his wife and thanked his running mate.

The Chicago visit is his last scheduled trip as president, and even the final flight on the presidential aircraft was tinged with wistfulness. It was Obama's 445th “mission” on Air Force One, a perk he has said he will miss when he leaves office, White House spokesman Josh Earnest said.

All told, Obama will have spent more than 2,800 hours or 116 days on the plane during his presidency.

Obama plans to remain in Washington for the next two years while his younger daughter, Sasha, finishes high school. Sasha did not attend the speech. The Obamas' older daughter, Malia, was there.

The president has indicated he wants to give Trump the same space that his predecessor, Republican President George W. Bush, gave Obama after leaving office by not maintaining a high public profile.