President Obama challenged world leaders Tuesday to condemn the violent attacks that have occurred against U.S. diplomats and missions in Libya and Egypt, suggesting that now is a key moment in the struggle for democratic freedom throughout the Middle East and North Africa.

Speaking to world leaders and diplomats gathered for the U.N. General Assembly, Obama told his audience that “it is the obligation of all leaders, in all countries, to speak out forcefully against violence and extremism.”

“It is time to marginalize those who — even when not resorting to violence — use hatred of America, or the West, or Israel as the central principle of politics,” Obama said in the fourth address of his presidency to the assembly. “For that only gives cover, and sometimes makes excuses, for those who do resort to violence.”

Obama used his appearance to defend the U.S. role in the Middle East and North Africa to an extent that he had not done before, calling on those gathered to help ensure that the unpredictable political transition underway in the region ends in democratic rule and economic opportunity. He cited the violent conflict in Syria, the Palestinian national movement and other regional struggles as opportunities to reaffirm American support for those seeking freedom.

But the president also acknowledged what he described as “the tensions between the West and an Arab world moving to democracy” — tensions he said have surfaced again in the recent attacks on Americans in Libya and Egypt.

He said they must be “honestly addressed,” then presented a strong defense of democratic values such as free speech, that he said should not be sacrificed despite the new challenges presented to governments and beliefs in the information age.

“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,” he said.

Turning to the dispute over Iran’s nuclear program, Obama adopted a sterner tone. He said time is running out for a diplomatic solution and echoed his previous position that the United States is committed to stopping Tehran from developing a nuclear weapon.

“A nuclear-armed Iran is not a challenge that can be contained,” he said. “It would threaten the elimination of Israel, the security of gulf nations and the stability of the global economy. It risks triggering a nuclear arms race in the region and the unraveling of the Non-Proliferation Treaty. That’s why a coalition of countries is holding the Iranian government accountable. And that’s why the United States will do what we must to prevent Iran from obtaining a nuclear weapon.”

The bulk of the 30-minute speech, however, was devoted to appealing for calm and tolerance in the aftermath of the protests and violence that swept many mainly Muslim countries this month in response to a YouTube video that disparaged the prophet Muhammad.

Invoking the death of the American ambassador to Libya, J. Christopher Stevens, and three others in an assault on a U.S. diplomatic post there on Sept. 11, Obama said: “There is no speech that justifies mindless violence. There are no words that excuse the killing of innocents. There is no video that justifies an attack on an embassy.”

Obama called the video “crude and disgusting,” but he did not apologize for it as protesters in Pakistan and elsewhere have demanded.

“I have made it clear that the United States government had nothing to do with this video, and I believe its message must be rejected by all who respect our common humanity,” the president said. “It is an insult not only to Muslims but to America as well.”

Obama warned repeatedly that democratic change — from Burma to Yemen — is threatened by the extremism occurring in the Middle East

“If we are serious about those ideals, we must speak honestly about the deeper causes of the crisis. Because we face a choice between the forces that would drive us apart and the hopes we hold in common,” Obama said.

“Today, we must affirm 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.”

Obama argued that banning the video would violate the constitutional principle of free speech and wouldn’t work anyway in the age of the smartphone.

“Like me, the majority of Americans are Christian, and yet we do not ban blasphemy against our most sacred beliefs,” he said. “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.”

That line drew laughter and applause from an audience that included leaders of U.S. adversaries such as Iran and North Korea.

Obama said the United States protects offending views “not because we support hateful speech,” but “because in a diverse society, efforts to restrict speech can quickly become a tool to silence critics and oppress minorities.”

The administration has struggled particularly hard to address the wave of violence sparked by the video in Pakistan, where anti-American sentiment is high and the billions in U.S. aid is often viewed with suspicion.

U.S. officials said Pakistan’s security services have done an able job of defending American diplomatic installations, but U.S. officials were dumbfounded last week when Pakistan’s railway minister offered $100,000 to anyone who kills the maker of the video.

The Pakistani government disavowed the bounty Monday, just hours before Secretary of State Hillary Rodham Clinton met President Asif Ali Zardari on the sidelines of the U.N. meeting. U.S. officials said afterward that she did not directly call on the Pakistani leader to fire the minister.

Senior U.S. officials later said that the entire Pakistani delegation had condemned the bounty, and one official who belongs to the same political party as the railway minister told Clinton that the party would soon consider the minister’s future role. The U.S. officials said they took that statement as an implicit promise to punish the minister, and one said the Americans were “comfortable with that response.”

The U.S. officials described the session on the condition of anonymity because they were not authorized to discuss the closed-door session on the record.