"As long as the threat from Iran persists, we will go forward with a missile defence system that is cost-effective and proven," he told a crowd of about 20,000 gathered in Hradcany Square, next to Prague Castle.
"Iran's nuclear and ballistic missile activity poses a real threat, not just to the United States, but to Iran's neighbours and our allies."
He hailed the "courageous" Czech Republic and Poland for "agreeing to host a defence against these missiles". Russia is strongly opposed to radar stations for a missile defence shield being established in countries that it still regarded as within its sphere of influence.
But Mr Obama also spoke of the potential for a rapprochement with Iran that would remove the need for such a system.
"If the Iranian threat is eliminated, we will have a stronger basis for security, and the driving force for missile defence construction in Europe will be removed."
Tehran, he said, had a choice. "We want Iran to take its rightful place in the community of nations, politically and economically. We will support Iran's right to peaceful nuclear energy with rigorous inspections. That is a path that the Islamic Republic can take."
The centrepiece of Mr Obama's speech was a declaration that because the United States had dropped two atom bombs on Japan in 1945 it had a "moral responsibility" to work towards securing "a world without nuclear weapons".
He said nuclear weapons were the "most dangerous legacy of the Cold War" and the risk of a nuclear attack had never been greater because "terrorists are determined to buy, build or steal one".
The crowd enthusiastically cheered the more idealistic parts of Mr Obama's speech but was relatively subdued when he spoke about his backing for missile defence.
Petr Sramek, 33, was among those disappointed that Mr Obama had not dropped a policy that was opposed by more than two thirds of Czechs.
"I really liked the clear message on nuclear disarmament but I am against the missile defence system. It is more about geopolitical influence then defence against missiles."
SCROLL TO CONTINUE WITH CONTENT
Get our best delivered to your inbox.
Arena Protivinska, 30, described herself as a "big fan" of Mr Obama but accused him of "hypocrisy" for urging world peace while also pushing forward with the missile shield.
"He sounded like George W Bush saying that we should be afraid in order to justify missile defence."
Speaking in a city chosen for the symbolism of its peaceful toppling of communism through the Velvet Revolution of 1989, Mr Obama denounced "fatalism" over nuclear proliferation and said he would lead a global effort to reduce and eventually eliminate nuclear weapons.
"As the only nuclear power to have used a nuclear weapon, the United States has a moral responsibility to act," he said. "We cannot succeed in this endeavour alone, but we can lead it.
"So today, I state clearly and with conviction America's commitment and desire to seek the peace and security of a world without nuclear weapons."
Mr Obama called for a reduction of the role of nuclear weapons in American national security strategy. He wanted to negotiate a new strategic arms reduction treaty with Russia - to which Moscow agreed in principle last week - and was seeking a treaty to end the production of fissile materials used in nuclear weapons.
He also announced that the US would host a global summit on nuclear security next year and that he would work to ratify the nuclear Comprehensive Test Ban Treaty, which was signed by former President Bill Clinton in 1999 but rejected by the US Senate.
He strongly condemned North Korea over its rocket launch, which came hours before his speech. He said Pyongyang had to be called to account. "This provocation underscores the need for action, not just at the UN Security Council, but in our determination to prevent the spread of these weapons," he said. "Rules must be binding, violations must be punished, words must mean something. The world must stand together to prevent the spread of these weapons. Now is the time for a strong international response."
Mr Obama's reference to the atom bombs that were dropped on Hiroshima and Nagasaki, killing as many as 220,000, was part of his effort to rebuild bridges with the world by promising, as he said in Strasbourg, "to listen to learn and to learn" and to acknowledge American failings.
Gary Samore, a White House adviser on arms control, indicated that Mr Obama's call for ridding the world of nuclear weapons should not be taken too literally. "In terms of a nuclear-free world, we recognise this is not a near-term possibility," he said. Rather, the call was an attempt to "seize the moral high ground" in order to increase pressure on countries such as North Korea and Iran.