Barack Obama has written an emotional letter to America on his final day in office, saying: "You made me a better President, and you made me a better man."

The outgoing commander-in-chief thanked US citizens for the honour of serving as 44th president in the note posted on Medium, adding that he would also leave one at the White House for Donald Trump.

"All that I've learned in my time in office, I've learned from you," he told his fellow Americans. "You have been the source of goodness, resilience, and hope from which I've pulled strength."

After a year of terrorist attacks and mass shootings, he said he had mourned with grieving families and singled out the "grace" of those at an African American church in Charleston, South Carolina, where Dylann Roof shot dead nine people in hopes of igniting a race war.


Mr Obama also praised "neighbours and communities who cared for each other during the worst economic crisis of our lifetimes."

At a time when many are expressing despair over the incoming administration, the departing president said he took heart from the hope of the next generation - graduates, new military officers, doctors and scientists who have helped injured soldiers walk and a paralysed man regain his sense of touch.

He also made some subtle digs at the President-elect in referring to issues on which they are divided. He spoke of the success of his Obamacare health scheme, which the President-elect has vowed to undo, and to the legal recognition of same-sex marriage. And he mentioned that even young children reminded us of our "obligations to care for refugees."

Mr Obama praised Americans for "decency, determination, good humour, and kindness", but reminded everyone that we need to work for our future, irrespective of party politics.

He reassured doubtful voters that even "when the arc of progress seems slow" we should remember the US is not about one person but about being united, and "the most important word is 'we'."

The President of eight years reminded us of his election campaign slogan: "Yes we can."

And he made it clear this isn't the end of his role in public life.

"I'll be right there with you every step of the way."