President Barack Obama has appealed to world leaders to reject attacks on US diplomatic missions in the Muslim world sparked by an anti-Islam video.
He called anew for the ouster of Syria's president without saying how to make it happen.
Mr Obama also told the UN General Assembly the United States "will do what we must" to keep Iran from getting nuclear weapons - a veiled threat of military force - one day after Iran's President Mahmoud Ahmadinejad said Israel would be "eliminated."
The US president reiterated his preference for a diplomatic solution but told Iran that "time is not unlimited."
Both appeared to brush aside a warning against "inflammatory" rhetoric from UN Secretary-General Ban Ki-moon, who said nations must not threaten military action and that the consequences of using force would be devastating.
Mr Ban also warned the 193-nation assembly that the door to Israeli-Palestinian peace may be closing "for good."
Qatari Emir Sheikh Hamad bin Khalifa al-Thani, reflecting growing frustration with the UN Security Council's deadlock on Syria's 18-month civil war, told the assembly that it is time for Arab nations to take matters into their own hands and "interfere" in Syria.
He did not offer details.
Attacks on diplomatic missions
Mr Obama's speech followed two weeks in which the United States suffered attacks on its diplomatic missions in Muslim nations in the Middle East, North Africa and Asia.
It was his final UN appearance before the 6 November US presidential election.
Beginning and ending his speech by evoking Christopher Stevens, the ambassador to Libya who died with three other Americans in an 11 September assault on the US consulate in Benghazi, Mr Obama made a plea for nations to unite against such attacks.
"It is the obligation of all leaders in all countries to speak out forcefully against violence and extremism," Mr Obama said.
"There is no speech that justifies mindless violence."
The violence in Libya, as well as attacks on US diplomatic missions in Egypt, Tunisia, Indonesia and other Muslim nations, was sparked by a video made in California that depicts the Prophet Muhammad as a womanizer, fool and child abuser.
Susilo Bambang Yudhoyono, president of the world's most populous Muslim-majority nation, Indonesia, called for a binding international treaty to "prevent incitement to hostility or violence based on religions or beliefs."
Mr Obama, while repeating his condemnations of the video as "crude and disgusting" and stressing the US government had nothing to do with its production, defended freedom of speech.
"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," Mr Obama said, drawing applause and some laughter.
"It is time to marginalize those who, even when not directly resorting to violence, use hatred of America or the West or Israel as the central organizing principle of politics, for that only gives cover, and sometimes makes an excuse for, those who do resort to violence," he added.
Obama says time not unlimited for Iran
Mr Obama is likely to have disappointed Israeli Prime Minister Benjamin Netanyahu with his comments on Iran because he did not lay down any "red lines" that the Israeli leader has demanded to trigger military action if Iran crosses them.
Iran says its nuclear program is solely for peaceful uses such as generating electricity or producing medical isotopes.
"Let me be clear: America wants to resolve this issue through diplomacy and we believe that there is still time and space to do so.
But that time is not unlimited," Obama said.
"The United States will do what we must to prevent Iran from obtaining a nuclear weapon," he added.
While some nations, notably in the Arab World, have called for more robust international action to stop the bloodshed in Syria, the UN Security Council has been deadlocked.
Russia and China have vetoed three resolutions condemning Damascus.
Qatar said it was time for action outside the United Nations.
"I think that it is better for the Arab countries themselves to interfere out of their national, humanitarian, political and military duties and do what is necessary to stop the bloodshed in Syria," bin Khalifa al-Thani said.
Syria has accused Qatar, Saudi Arabia and Turkey of supplying arms to the Syrian rebels.
US officials have privately made clear that they have no appetite for a military intervention without UN sanction in another Muslim country just as they have wound down the US war in Iraq and are largely pulling out of Afghanistan by 2014.
"The international community should not look the other way as violence spirals out of control," Mr Ban said.
Mr Obama provided no clear direction forward.
"As we meet here, we again declare that the regime of Bashar al-Assad must come to an end so that the suffering of the Syrian people can stop and a new dawn can begin," he said, calling for harmony among Sunnis, Alawites, Christians and Kurds in Syria.
"That is the outcome that we will work for, with sanctions and consequences for those who persecute and assistance and support for those who work for this common good," he said.
Brazilian President Dilma Rousseff sounded a note of caution. "There is no military solution to the Syrian crisis," she told the General Assembly.
"Diplomacy and dialogue are not just our best option, they are the only option," she said.
A year after the Palestinians mounted an ultimately failed effort for UN membership, Mr Obama passed quickly over the Arab-Israeli conflict.
"The road is hard, but the destination is clear - a secure Jewish state of Israel and an independent, prosperous Palestine," Mr Obama said.
"America will walk alongside all who are prepared to make that journey."
Mr Ban offered a pessimistic assessment, suggesting that time had nearly run out for such a negotiated solution.
"The two-state solution is the only sustainable option. Yet the door may be closing, for good," he said.