"I do believe that it is the obligation of all leaders, in all countries, to speak out forcefully against violence and extremism," Obama said in a speech to the annual gathering of the United Nations General Assembly.
Obama also condemned the anti-Muslim video that helped spark the recent attacks, calling it "cruel and disgusting." But he strongly defended the U.S. Constitution's protection of the freedom of expression, "even views that we profoundly disagree with."
With U.S. campaign politics shadowing every word, Obama also warned that time to peacefully curb the Iranian nuclear crisis is running out.
He said there is "still time and space" to resolve the issue through diplomacy. But that time is not unlimited."
"Make no mistake: A nuclear-armed Iran is not a challenge that can be contained. It would threaten the elimination of Israel, the security of Gulf nations and the unraveling of the nuclear non-proliferation treaty," he said.
The foreign minister of Indonesia, the nation with world's largest Muslim population, said Obama's speech was a "clarion call" for all nations to shun intolerance and he expected Muslim nations to react positively.
"There will be a lot of sympathy. It is an issue that galvanizes all of us," Foreign Minister Marty Natalegawa told The Associated Press. But he added that freedom of expression should be exercised with consideration to morality and public order.
Republican presidential nominee Mitt Romney has accused Obama of not being tough enough on Iran and of turning his back on Israel and other allies in the Middle East. Romney also has said he doesn't have much faith in peace prospects between Israelis and Palestinians.
Obama told the U.N.: "Among Israelis and Palestinians, the future must not belong to those who turn their backs on the prospect of peace."
Romney in separate remarks to a global conference sponsored by former President Bill Clinton, said the attack at the U.S. Consulate in Benghazi, Libya, that took the life of the U.S. ambassador and three other U.S. citizens was an act of terrorism.
Obama mentioned the slain U.S. ambassador, Christopher Stevens, several times in his address.
"Today, we must declare that our future will be determined by people like Chris Stevens and not by his killers. Today, we must declare that this violence and intolerance has no place among our United nations," he said.
Unlike Romney, Obama has not specifically called the attacks in Libya and other U.S. missions terrorism.
Obama said that "at a time when anyone with a cellphone can spread offensive views around the world with the click of a button," the notion that governments can control the flow of information is obsolete.
"There is no speech that justifies mindless violence," such as the attack that left the four Americans dead in Libya, Obama said.
"The strongest weapon against hateful speech is not repression, it is more speech - the voices of tolerance that rally against bigotry and blasphemy and lift up the values of understanding and mutual respect."
Obama said that the United States "will be relentless in tracking down the killers and bringing them to justice." And he said he appreciated "that in recent days, the leaders of other countries in the region - including Egypt, Tunisia and Yemen - have taken steps to secure our diplomatic facilities and called for calm. So have religious authorities around the globe."v The president said there was no way the United States would have just banned the offensive video that helped trigger the attacks, as some leaders in the Muslim world have advocated.
"Like me, the majority of Americans are Christian, and yet we do not ban blasphemy against our most sacred beliefs," Obama said.
"Moreover, as president of our country and commander in chief of our military, I accept that people are going to call me awful things every day, and I will always defend their right to do so," he said, drawing laughter from his audience.
Running through Obama's speech was an overall theme that leaders of the Muslim world should also stand up for freer speech and oppose those who vent their anger with violence.
"There are no words that excuse the killing of innocents. There is no video that justifies an attack on an embassy. There is no slander that provides an excuse for people to burn a restaurant in Lebanon or destroy a school in Tunis or cause death and destruction in Pakistan," Obama said.
"More broadly, the events of the last two weeks speak to the need for all of us to address honestly the tensions between the West and an Arab world moving to democracy," he said.
But, he added, "Just as we cannot solve every problem in the world, the United States has not, and will not, seek to dictate the outcome of democratic transitions abroad, and we do not expect other nations to agree with us on every issue."
"Nor do we assume that the violence of the past weeks, or the hateful speech by some individuals, represents the views of the overwhelming majority of Muslims - any more than the views of the people who produced this video represent those of Americans."
Turning to the rising violence in Syria, Obama told the U.N. delegates, "The future must not belong to a dictator who massacres his people. If there is a cause that cries out for protest in the world today, it is a regime that tortures children and shoots rockets at apartment buildings. We must remain engaged to assure that what began with citizens demanding their rights does not end in a cycle of sectarian violence."
"Together, we must stand with those Syrians who believe in a different vision - a Syria that is united and inclusive, where children don't need to fear their own government and all Syrians have a say in how they are governed- Sunnis and Alawites, Kurds and Christians."
Obama also noted some hopeful developments in the world in the nearly four years he's been in office.
"The war in Iraq is over, and our troops have come home. We have begun a transition in Afghanistan, and America and our allies will end our war on schedule in 2014," he said. "Al-Qaida has been weakened, and Osama bin Laden is no more. Nations have come together to lock down nuclear materials, and America and Russia are reducing our arsenals."
Summing up, Obama said, "true democracy - real freedom - is hard work."
Declaring it is time to leave "the call of violence and the politics of division behind," Obama said: "We cannot afford to get it wrong. We must seize this moment. And America stands ready to work with all who are willing to embrace a better future."