Amid mounting unrest in the Middle East, President Obama today warned Iran that the time for diplomacy is running out and challenged global leaders to confront the "deeper causes" of the crises, saying the turmoil serves as a reminder that true democracy is "hard work."

"We face a choice between the forces that would drive us apart, and the hopes we hold in common," the president told the United Nations General Assembly.

"The attacks of the last two weeks are not simply an assault on America," he argued. "They are also an assault on the very ideals upon which the United Nations was founded – the notion that people can resolve their differences peacefully; that diplomacy can take the place of war; and that in an interdependent world, all of us have a stake in working towards greater opportunity and security for our citizens."

Two years after the start of the Arab Spring and six weeks before U.S. elections, the president insisted "progress" has been made, but made clear "democracy does not end with the casting of a ballot."

"True democracy demands that citizens cannot be thrown in jail because of what they believe, and businesses can be opened without paying a bribe. It depends on the freedom of citizens to speak their minds and assemble without fear; on the rule of law and due process that guarantees the rights of all people," he said.

As tensions rise over Iran's nuclear ambitions and the United States leads a mine-clearing exercise in the Persian Gulf, Obama also warned Tehran that the United States will "do what we must" to prevent it from obtaining a nuclear weapon.

The president argued there is still "time and space" for diplomacy, but said "time is not unlimited."

"We respect the right of nations to access peaceful nuclear power, but one of the purposes of the United Nations is to see that we harness that power for peace. Make no mistake: a nuclear-armed Iran is not a challenge that can be contained," he said.

Obama, however, stopped short of giving Iran an ultimatum, or "red lines" that it cannot cross, as Israeli Prime Minister Benjamin Netanyahu has demanded.

A nuclear Iran, Obama said, "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 is why a coalition of countries is holding the Iranian government accountable. And that is why the United States will do what we must to prevent Iran from obtaining a nuclear weapon," he said.

Obama opened his annual remarks today with a tribute to U.S. Ambassador Chris Stevens, who was killed, along with three other Americans, in the attack on the U.S. consulate in Benghazi, Libya, saying he "embodied the best of America."

"Understand that America will never retreat from the world. We will bring justice to those who harm our citizens and our friends," he said.

The president condemned the amateur anti-Islam film that has sparked violent protests across the region as "crude and disgusting" but vehemently defended free speech.

"Americans have fought and died around the globe to protect the right of all people to express their views, even views that we disagree with," he said.

The strongest weapon against hateful speech, Obama said, is "not repression, it is more speech."

"On this we must agree: there is no speech that justifies mindless violence," he said.

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

The president challenged his global counterparts to "seize this moment" and speak out forcefully against violent extremism.

"It is time to leave the call of violence and the politics of division behind. On so many issues, we face a choice between the promise of the future, or the prisons of the past," he said. "We cannot afford to get it wrong."