President Barack Obama yesterday addressed the paradox of accepting the Nobel peace prize in Oslo while escalating the conflict in Afghanistan, invoking the concept of "the just war" to defeat evil.

In what amounted to a personal testimony, he portrayed himself as a moral man doing his best in an imperfect world."We must begin by acknowledging the hard truth: we will not eradicate violent conflict in our lifetimes. There will be times when nations – acting individually or in concert – will find the use of force not only necessary but morally justified," he said.

He cited, as examples of the "just war", the fight against Hitler, the confrontation with Saddam Hussein after the invasion of Kuwait and Nato involvement in the Balkans. In an echo of Tony Blair in his Chicago speech in 1999, Obama said there were often times when humanitarian intervention became essential.

He noted the ambivalence of the world towards US military actions, but argued that failed states such as Somalia and Afghanistan could not be left to fester.

"Inaction tears at our conscience and can lead to more costly intervention later. That's why all responsible nations must embrace the role that militaries with a clear mandate can play to keep the peace."

Obama, who was still rewriting his speech on his overnight flight from Washington, recognised critics who said it was too soon for him to receive such an award, given he had no accomplishments yet to justify it. "I would be remiss if I did not acknowledge the considerable controversy that your generous decision has generated," he said, to laughter.

The 108th recipient of the prize expressed humility, saying he could not be compared with giants of history such as Dr Martin Luther King and Nelson Mandela who had received the prize. He said too that he was only at the start of his labours on the world stage, not the end.

He then turned to the crux of the criticism. "Perhaps the most profound issue surrounding my receipt of this prize is the fact that I am the commander-in-chief of the military of a nation in the midst of two wars. One of these wars is winding down. The other is a conflict that America did not seek; one in which we are joined by 42 other countries – including Norway – in an effort to defend ourselves and all nations from further attacks," he said.

He accepted the arguments of King and Gandhi for passive resistance. "But as a head of state sworn to protect and defend my nation, I cannot be guided by their examples alone. I face the world as it is and cannot stand idle in the face of threats to the American people. For make no mistake: evil does exist in the world.

"A non-violent movement could not have halted Hitler's armies. Negotiations cannot convince al-Qaida's leaders to lay down their arms. To say that force may sometimes be necessary is not a call to cynicism – it is a recognition of history; the imperfections of man and the limits of reason," he said. While not referring to George Bush, he sought to differentiate himself from him, presenting himself as a reluctant war leader and one who would adhere to the norms of international law.

He was listened to in silence throughout most of the speech but applause came when he said: "Let us reach for the world that ought to be – that spark of the divine that still stirs within each of our souls."

The Nobel chairman, Thorbjorn Jagland, opening the ceremony, said of Obama: "Dr King's dream has come true."

Security was tight in Oslo. A 74km-wide no-fly zone for small planes and helicopters caused delays to air traffic to and from the capital. "This is completely ridiculous," said Christian Ingvardsen, a 38-year-old businessman, as his plane to Norway was delayed at Copenhagen airport. "I like Obama but this is getting completely out of hand. Is it like that when he travels in the US? Do they really shut down Chicago like this?"

Despite the restrictions and the military-like atmosphere, there was still much enthusiasm in town about Obama's visit – the first by a US president in office since Bill Clinton in 1999. As Obama's 23-car convoy raced past Kristian IV's street to the royal palace earlier yesterday, many passersby cheered with joy at seeing the world's most powerful man travelling through their city.