"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 limited."
"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.
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."