President Barack Obama has challenged the international community to confront the causes of Middle East turmoil, saying the world faces “a choice between the forces that would drive us apart and the hopes we hold in common.”
His speech to an annual gathering of world leaders at the UN General Assembly was his last before the November election, and campaign politics shadowed his words as he also spoke forcefully on Iran's nuclear programme, the peace prospects between Israelis and Palestinians and the tensions that can come with freedom of speech.
"I do believe that it is the obligation of all leaders, in all countries, to speak out forcefully against violence and extremism," Mr Obama said.
The president condemned the amateur anti-Muslim video made in the US that helped spark the recent protests that killed dozens of people, including the US ambassador to Libya, Chris Stevens, calling it "cruel and disgusting."
"There is no speech that justifies mindless violence," Mr Obama said.
But he strongly defended the US Constitution's protection of the freedom of expression, "even views that we profoundly disagree with."
Mr Obama also warned that the time to peacefully curb the Iranian nuclear crisis is running out. Iran insists its nuclear programme is peaceful, but fears that it is pursuing nuclear weapons have led Israel to threaten an attack.
Mr Obama said there is "still time and space" to resolve the issue through diplomacy, but he said 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 unravelling of the nuclear non-proliferation treaty," he said.
Republican presidential nominee Mitt Romney has accused Mr Obama of not being tough enough on Iran and of turning his back on Israel and other allies in the Middle East. Mr Romney also has said he does not have much faith in peace prospects between Israelis and Palestinians.
Mr Obama told the UN: "Among Israelis and Palestinians, the future must not belong to those who turn their backs on the prospect of peace."
Mr Romney in separate remarks to a global forum sponsored by former president Bill Clinton, said the attack at the US Consulate in Benghazi, Libya, that took the life of the US ambassador and three other US citizens was "a terrorist attack."
Mr Obama mentioned the US ambassador 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.
Mr Obama has not specifically called the attack in Libya terrorism, but Secretary of State Hillary Clinton and Mr Obama's top spokesman have said it was a terrorist attack.
Mr 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.
"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," he said.
The president said the United States would never have just banned the offensive video, 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," he 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, to laughter from his audience.
Running through his speech was the theme that leaders in the Muslim world also should 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," he 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."Reuse content