Barack Obama rose to power as the country's first African American president with message of hope and boundless optimism for the future.

"If there is anyone out there who still doubts that America is a place where all things are possible...who still questions the power of our democracy, tonight is your answer," he told crowds in Chicago in 2008 after winning the election.

In all the years since he never wavered from his mission to help foster in America what he once called the "renewal of morality".

Unlike Richard Nixon, Bill Clinton and so many others before him, this is a president unblemished by scandal.

The president acted presidential even behind closed doors: even his closest aides fail to recall moments when Mr Obama gave way to roiling anger. Emotions have rarely muddled the academic rigor of his mind.

White House staffers have nicknamed him the 'Colombo president', after the famous television detective who always catches the killer with his questions.

So inquisitive is Mr Obama, one senior aide said, that he has changed the traditional length of memos written for a sitting president. "A science brief was placed on his desk. It had been kept to two pages as is usual," the aide said. "It came back the next day with three words written by the president in the top right hand corner: 'where's the rest?'"

It is because of this that his speech on Tuesday night was all the more remarkable: after eight years of preaching change and hope, Mr Obama ended his leadership with an urgent and fearful warning about the state of American democracy.

It was a thinly veiled slight to the divisive rhetoric of Donald Trump's election campaign, which included attacks on Muslims, the disabled, women and immigrants.

"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," Mr Obama said.

Mr Obama has been criticised by African American communities for failing to address race issues in the country during his time in office.

But in these final moments, he warned of racism as a poison to democracy. He called on African Americans and other minorities to tie their " own struggles for justice" to the challenges that a lot of people in this country face – including the middle-aged white man who "may seem like he’s got all the advantages, but who’s seen his world upended by economic, cultural, and technological change".

And he called on white Americans to acknowledge that "the effects of slavery and Jim Crow didn’t suddenly vanish in the ‘60s".

Mr Obama made only passing reference to the next president. When he noted he would soon be replaced by the Republican, his crowd began to boo.

"No, no, no, no, no," Obama said. One of the nation's great strengths, he said, "is the peaceful transfer of power from one president to the next."

Mr Obama may have done all he could to help the peaceful transition of power to the president-elect, but he became emotional as he prepared to pass the baton of the country he loved to a man whom he does not trust.

He became urgent, a tear in his eye, as he talked of needing to "guard against a weakening of the values that make us who we are".

Brushing away tears with a handkerchief, Mr Obama paid tribute to the sacrifices made by his wife - and by his daughters, who were young girls when they entered the big white home on Pennsylvania Avenue and leave as young women.

He praised first lady Michelle Obama for taking on her role "with grace and grit and style and good humour" and for making the White House "a place that belongs to everybody."

As he prepared to step away from the stage one final time he seemed to be passing on the stewardship of America not to Mr Trump, but to the nation's people.

Barack Obama: I am asking you to believe

Barack Obama posted on Twitter shortly after finishing his speech: "Thank you for everything. My last ask is the same as my first. I'm asking you to believe—not in my ability to create change, but in yours."

Thank you for everything. My last ask is the same as my first. I'm asking you to believe—not in my ability to create change, but in yours.

The tech wizards that brought Obama to fame

The Telegraph's Ruth Sherlock writes:

Meet the men behind the wizardly digital strategy that fueled Barack Obama's rise to the presidency:

Sam Falkoff said he was the recipient of the first cheque that the Obama campaign wrote. A senior systems engineer he helped set up the technology that helped finesse the campaign's renowned ability get out the vote. Mr Falkoff recalled the games they would play at the beginning: "I named all our internet servers after the Boston Red Socks baseball players," he said.

These three men are the tech wizards behind #Obama's 2008 campaign. Sam Falkoff (left) named their internet servers after Boston Red Socks pic.twitter.com/yOwb7g5wKU

Kevin Malover was the chief technology officer in the early campaign days in 2007: "At the time Barack Obama was a long shot with a funny name and no money," he said. "But I was attracted by his respectful rhetoric. Instead of engaging in the politics of tearing things down he painted a bright future." "I am going to miss the texture of his speeches and well thought out responses that he gives to problems. Now we are going to have a president who thinks he can sum up the complexity of the Syrian war in 180 characters of a Tweet."

Jim Boyce, a technology consultant in Mr Obama's first campaign said: "After everything it's bitter sweet to see this end on these terms, with Trump in the White House."

'We are his family'

The crowds are streaming out of the hall now. Many have tears in their eyes. The reality of Barack Obama leaving the White House is starting to sink in, writes Ruth Sherlock.

He made Chicago his home town, and so, despite the cavernous size of the convention centre, the evening has an intimate feel.

So many of the people I have spoken to here tonight met Mr Obama at some point during his career - when he was a community organiser in the bedraggled projects of South Chicago, or when he was their senator and political rising star.

Tina and Tom Finch, have a photograph on their phone of a young Mr Obama holding their child - Giselle - in his arms.

"I was here in this very convention centre listening to the speech when he was he was elected in 2008," Mr Finch said. "Tonight he brought it home again.

One mention of Trump

The whole speech addressed an America that was divided and has experienced an election full of "corrosive political dialogue." Yet, Mr Obama refrained from attacking his successor. Indeed, he mentioned him only once by name - an omission which spoke volumes.

There are a lot of tears in the arena

Ruth Sherlock reports

In his final address to the nation, Barack Obama might have been expected to use the time to remind America of his presidential successes, and trying to help shape how historians will come to define his legacy. But instead, tonight's speech is an extraordinary appeal to Americans to recognise and work to resolve matters that Mr Obama sees an existential threat to the country's democracy.

It is a less than subtle warning to Donald Trump, and an admonition of the rhetoric used by his successor on the campaign trail. Divisions, he said, are a threat to American freedom, and then singled out the very rhetoric that lay at the core of Mr Trump's election pitch as a propagator of such animosity: the framing of "every economic problem", he said, as a competition between a white working class and an "undeserving minority".

And failing to invest in immigration, he said, will only imperil America more. Instead of attacking one another, he urged Americans to look for the "reservoir of goodness" in one another and keep their respect for the "scope of freedom", and the "rule of law".

Praising Michelle

'We are all citizens'

"For all our outward differences, we all share the same title: citizen... Our democracy needs you."

"If you're tired of arguing with people on the internet, try talking to them in real life." If something needs fixing, he says, do something about it. If you're disappointed in elected officials, try and run for office yourself.

Defending democracy

"Our democracy is threatened when we take it for granted," he says, saying they must make it easier, not harder to vote.

All of this depends on "our responsibility of citizenship."

Talking of the constitution, he says "we the people give it meaning". He says nobody should be alienated and laments the "corrosive political dialogue". Ties are weakened when some people are defined as more American than others.

Climate change, rule of law and terrorism

Calling for more to be done to tackle climate change, he says denying the problems "betrays future generations".

He goes on to say the rule of law is being challenged by fanatics and autocrats - those who "fear change". Hailing the military and intelligence community, he trumpets the fact there has been no foreign terror attack in the US in the past 8 years.

Ruth Sherlock reports

This is exactly the soaring oratory that defines Barack Obama. His eloquent, powerful, hopeful rhetoric helped him as a young senator to vault into the position of commander-in-chief. In these eight years Americans have turned to his words for comfort in difficult times. After terror attacks and mass shootings, he has repeatedly taken to the airwaves to call for a message of unity and hope. He holds himself in a manner that is, utterly presidential. It is for this skill and this use of language that many Americans will remember him.

Unifying call

He is calling for solidarity as America moves forward, before ticking off more achievements under his time in office. "We need economic opportunity" and he notes that poverty is falling again. Unemployment rate is near a 10-year low.

Only if democracy works

On Trump, he says he promised a smooth transition. "It's up to all of us...our potential will only be realised if our democracy works. If our politics reflects the decency of our people. Only if all of us restore the sense of common purpose, that we badly need right now."

'The capacity to change'

'Our unalienable rights'

Obama is invoking the Declaration of Independence's teachings about equality and unalienable rights, and its challenge to Americans to take it upon themselves to defend those rights and improve America's democracy.

"This is the great gift our Founders gave us. The freedom to chase our individual dreams through our sweat, toil, and imagination - and the imperative to strive together as well, to achieve a greater good."

'Our bold experiment'

During his time in Chicago, Obama says he witnessed "the quiet dignity of working people in the face of struggle and loss." He argues change is only possible "when ordinary people get involved" and join forces to demand progress.

"After eight years as your president, I still believe that. And it's not just my belief. It's the beating heart of our American idea - our bold experiment in self-government."

Thank you

The President begins by thanking the American people - they have "kept him honest, inspired and kept him going". He then looks back at when he first came to Chicago.

“I first came to Chicago when I was in my early twenties, still trying to figure out who I was; still searching for a purpose to my life," "It was in neighbourhoods not far from here where I began working with church groups in the shadows of closed steel mills. It was on these streets where I witnessed the power of faith, and the quiet dignity of working people in the face of struggle and loss."

And here he comes...

National anthem time

Supporters are looking for one last dose of 'hope'

This is how Janaya Shaw, 39, a teacher at a Chicago college feels about tonight, writes Ruth Sherlock.

"This is a history defining moment. I am sad to see him go. I just wish that in his speech tonight he can give us some more hope, some more positive thoughts that can help us through the next years without him.

"This is the first incoming president that makes me wonder about the state of our country. I cried like a baby when Obama won in 2008.

"My grandmother always said when I was small that she wished America could have an African American president. She died just a few years before it happened, so I always think of her when I think of him."

A special moment for families

Elizabeth Evan's two children were six and eight years of age when Barack Obama won the presidential election in 2008, writes Ruth Sherlock at McCormick Place in Chicago.

"I brought them then to Obama's election party the night of the Illinois primary and now we are here again as a family to see him say goodbye."

For Mrs Evans and Ben and Natalie, her son and daughter, Mr Obama will go down in history as one of America's great leaders - in particular for the way he helped portray America to the rest of the world.

"He didn't present us as a forceful democracy exporter, but as a nation who works alongside the other leading countries of the world," Mrs Evans said.

Mrs Evans, Ben and NatalieCredit:
Ruth Sherlock

Natalie, who is now in high school, said Mr Obama also worked on the issues that young people care about - women's rights, education and gay rights.

Ben, who is now studying physics at university said that his legacy will in large part depend on how many of his policies survive Donald Trump's first 100 days.

A moment for nostalgia

First lady Michelle Obama, Vice President Joe Biden, his wife, Jill Biden, and many current and former White House staff members and campaign workers were expected to attend the speech tonight.

"The president is not one to be overly sentimental, but given the circumstances, I think it would be unrealistic to expect anybody to not feel some nostalgia for this moment," his spokesman, Josh Earnest told reporters.

Even the final trip on the presidential aircraft was a moment tinged with wistfulness. It was Obama's 445th trip on the presidential aircraft, a perk he has said he will miss when he leaves office. All told, he will have spent more than 2,800 hours or 116 days on the plane during his presidency, Mr Earnest said.

'A bitter sweet night'

Marina Jenkins waited in the queue to the convention halls with friends who have all worked with Barack Obama since 2008, and some of whom are in his administration, writes Ruth Sherlock in Chicago.

"This is a bitter sweet night. A lot of us were with Obama in 2007. Now we are all uniting again together for one last time.

"I almost started crying this morning thinking about what's to come with Donald Trump. But then I got here and met up with all the people who have worked so hard to make the president's vision a reality. A lot of these people are still staying in community activism, and I know they will not stop their work just because he is out of office."

Most memorable moments

This speech is different

No stranger to high-stakes speeches, Mr Obama rose to national prominence on the power of his oratory. But this speech is different, White House officials have told AP.

Determined not to simply recite a history of the last eight years, Mr Obama directed his team to craft an address that would feel "bigger than politics" and speak to all Americans - including those who voted for Mr Trump.

His chief speechwriter, Cody Keenan, started writing it last month while Obama was vacationing in Hawaii, handing him the first draft on the flight home. By late Monday Mr Obama was immersed in a fourth draft, with Keenan expected to stay at the White House all night to help perfect Mr Obama's final message.

President Barack Obama steps off Air Force One during his arrival at O'Hare International Airport in ChicagoCredit:
AP

Ahead of his speech, the president acknowledged that the chaos of Washington makes it easy to lose sight of the role American citizens play in democracy. He said that while he leaves office with his work unfinished, he believes his administration made the US "a stronger place for the generations that will follow ours."

Seeking inspiration, Mr Obama's speechwriters spent weeks poring over his other momentous speeches, including his 2004 keynote at the Democratic National Convention and his 2008 speech after losing the New Hampshire primary to Hillary Clinton. They also revisited his 2015 address in Selma, Alabama, that both honoured America's exceptionalism and acknowledged its painful history on civil rights.

Former aides were brought back to consult on the speech, including advisers David Axelrod and Robert Gibbs, and former speechwriter Jon Favreau, said the officials.

What is Obama's legacy?

What next for Obama?

As his time in the White House comes to an end, what will Obama do to fill his time? Golf? Teaching? Running an NBA team? Harriet Alexander looks at what the future holds for the outgoing president.

Mr Obama’s next few years will be far more challenging that he had imagined – following his direct predecessor George W Bush into quiet retreat with his watercolours will not be an option.

The outgoing president announced before the election that he would remain in Washington, until his youngest daughter Sasha finishes school in 2019. The Obamas will live in the Kalorama neighborhood, in a Tudor-style home rented from Bill Clinton’s former press secretary, and will become the first First Family to remain in the capital since Woodrow Wilson was president.

Yet where he was once expected to take a quiet, “elder statesman” role, he is now likely to be far more involved than he had imagined – given both Mr Trump’s polemic policy agenda, and the flailing Democrat party left after Mrs Clinton’s defeat.

Obama's best quotes down the years

Contrasts in style

Barack Obama has admitted that in many ways, he and his successor Donald Trump are opposites - and that's certainly true when giving speeches.

From hope to fear, David Millward looks at the contrasting speeches of the president and the president-elect.

Few, even opponents, would dispute that Barack Obama is a fine orator while Donald Trump makes no claim to be a modern Cicero, arguing he should be judged by his deeds rather than words.

The outgoing president's carefully honed speeches are finely crafted, while a study of Mr Trump's syntax found it was akin to a third grader - a child of of eight or nine.

But as the campaign proved, the Trump style was pretty effective in getting the message across.

It is not just the standard of oratory which is markedly different, but the two men have struck a very different tone in their speeches.

Mr Obama's message has often been one of hope, voicing a belief that America should raise its sights to be a beacon for the rest of the world, setting the pace in tackling climate change and promoting democratic values.

On the campaign trail Mr Trump's message was that America was broken and only he could fix it by making the country "great again".

'He did it alone in a face of a war, a tornado' of opposition

The Telegraph's Ruth Sherlock is in Chicago and has been talking to people about Mr Obama's time in office.

Gary Hunter is Chicago pastor and professional photographer, who has spent nine years taking pictures of President Barack Obama. His collection of images includes stills from the Obamas' historic visit to Cuba last year.

And before Mr Obama moved to the White House the two men where neighbours in Chicago.

"We go back a long long way," Mr Hunter said in the lobby of the convention centre where Mr Obama will give his farewell address. "People think I am his personal Photographer because he hugs me when he sees me."

Pondering on Mr Obama's legacy he said: "Being able to get it all done in the middle of a fight. It's a sign that you are the greatest when you can get everything done - every past president promised a form of Obamacare but failed. But he did that and more, and he did it alone in a face of a war, a tornado (of Republican opposition)."

Obama 'still believes'

In his parting message to the nation, President Barack Obama is declaring his continued faith in the ability of all Americans to bring about powerful national change, despite the trials of the last eight years that so often stood between him and his goals, AP reports.

Mr Obama plans to reflect on his origins as a community organiser who witnessed "the quiet dignity of working people in the face of struggle and loss." He argues change is only possible "when ordinary people get involved" and join forces to demand progress.

"After eight years as your president, I still believe that," Mr Obama says in excerpts of his speech released in advance by the White House. "And it's not just my belief. It's the beating heart of our American idea - our bold experiment in self-government."