In the speech of his lifetime, he paid tribute to the struggle and sacrifice of America’s pioneers and vowed to meet the challenges that face him.

And he declared America had chosen “hope over fear, unity of purpose over conflict and discord”.

But he acknowledged that the country was in “the midst of crisis”, with a weakened economy and at war “against a far-reaching network of violence and hatred”.

In the inspirational speech, he told the cheering crowd: “The challenges we face are real. They are serious and they are many. They will not be met easily or in a short span of time. But know this, America – they will be met.

“On this day, we gather because we have chosen hope over fear, unity of purpose over conflict and discord.

“The time has come to reaffirm our enduring spirit, to choose our better history, to carry forward that precious gift, that noble idea, passed on from generation to generation, the God-given promise that all are equal, all are free, and all deserve a chance to pursue their full measure of happiness.

“In reaffirming the greatness of our nation, we understand that greatness is never a given. It must be earned.”

He continued: “Starting today, we must pick ourselves up, dust ourselves off, and begin again the work of remaking America. All this we can do. And all this we will do.”

Addressing the war on terror, he said: “America is a friend of each nation and every man, woman, and child who seeks a future of peace and dignity.

“Our power alone cannot protect us, nor does it entitle us to do as we please.

“We will begin to responsibly leave Iraq to its people, and forge a hard-earned peace in Afghanistan.

“With old friends and former foes, we will work tirelessly to lessen the nuclear threat, and roll back the spectre of a warming planet.

“And for those who seek to advance their aims by inducing terror and slaughtering innocents, we say to you now that our spirit is stronger and cannot be broken, you cannot outlast us, and we will defeat you.”

The President referred to America as “a nation of Christians and Muslims, Jews and Hindus – and non-believers”.

He added: “We are shaped by every language and culture, and because we have tasted the bitter swill of civil war and segregation, and emerged from that dark chapter stronger and more united, we cannot help but believe that the old hatreds shall someday pass, that as the world grows smaller, our common humanity shall reveal itself, and that America must play its role in ushering in a new era of peace.

“To the Muslim world, we seek a new way forward, based on mutual interest and mutual respect. To those leaders around the globe who seek to sow conflict, or blame their society’s ills on the West – know that your people will judge you on what you can build, not what you destroy.

“Our challenges may be new. The instruments with which we meet them may be new. But those values upon which our success depends – hard work and honesty, courage and fair play, tolerance and curiosity, loyalty and patriotism – these things are old. These things are true. What is demanded then is a return to these truths. This is the price and the promise of citizenship.

“This is the meaning of our liberty and our creed – why men and women and children of every race and every faith can join in celebration across this magnificent mall, and why a man whose father less than 60 years ago might not have been served at a local restaurant can now stand before you to take a most sacred oath.”

He went on to quote George Washington, America’s first president, who said: “Let it be told to the future world that in the depth of winter, when nothing but hope and virtue could survive that the city and the country, alarmed at one common danger, came forth to meet it.”