President Obama addresses the General Debate of the 71st Session of the United Nations General Assembly on Sept. 20 at the U.N.’s headquarters in New York. (Justin Lane/EPA)

President Obama, in his final speech to the United Nations Tuesday, made an impassioned plea on behalf of a liberal world order that he admitted was under growing threat from wars in the Middle East and rising nationalism at home and in Europe.

Speaking to the U.N. General Assembly for the eighth and last time as president, Obama sought to rise above the conflicts of the moment and outline a future of international cooperation, stressing the importance of the global liberal institutions formed after World War II, including the United Nations.

“The world is by many measures less violent and more prosperous than ever before,” Obama said. But he acknowledged a growing global unease, fueled by terrorism and economic anxiety, which has led some Western politicians, including Republican nominee Donald Trump, to call for tough, new restrictions on immigration and global trade.

Obama often seemed to be speaking simultaneously to history and to an American electorate facing a historic choice.

The problems plaguing the world called for a “course correction,” the president said. He then catalogued the crises that have exposed “deep fault lines in the existing international order,” describing the financial disruptions caused by globalization, chaos in the Middle East and the massive refu­gee flows into Europe.

At the United Nations General Assembly on Sept. 20, President Obama called on several nations with which he has had contentious relations to abide by international rules and do more to improve cooperation on a global level. (Reuters)

“Our societies are filled with uncertainty and unease and strife,” he said. “Despite enormous progress, as people lose trust in institutions, governing becomes more difficult and tensions between nations become more quick to surface.”

Obama rejected the strongman, top-down model pushed by many of his international rivals, including Russian President Vladi­mir Putin and Chinese President Xi Jinping. In the same breath he criticized those who push religious fundamentalism, aggressive nationalism and a “crude populism” that promises to return citizens to a “better and simpler age free of outside contamination” — a not-so-veiled reference to Trump’s campaign promise to “Make America Great Again.”

“We cannot dismiss these visions,” Obama said. “They are powerful.”

Throughout his presidency, Obama has stressed the importance of diplomacy and international organizations, such as the United Nations. From his earliest days as a presidential hopeful he has preached the importance of reaching out to long-standing enemies.

Obama used his speech Tuesday to try to cement that legacy, pointing to his administration’s efforts to restore relations with Cuba and Burma, and its historic agreement with Iran last year.

“When Iran agrees to accept constraints on its nuclear program, that enhances global security and enhances Iran’s ability to work with other nations,” Obama said.

The days leading up to Obama’s last United Nations address, like much of his presidency, were dominated by concerns about war and terrorism. Obama’s remarks came one day after a manhunt led to the capture of a suspect linked to bombings in New York and New Jersey and hours after a tenuous cease-fire in Syria seemed to have collapsed. There were reports that Syrian or Russian aircraft had struck an aid convoy near Aleppo, just days after planes from the U.S.-led alliance mistakenly struck Syrian troops.

Obama steered clear of these topics in his speech, focusing on his broader vision for preserving the international order.

The president spoke of the economic unease caused by globalization, which has manifested itself during the presidential race in widespread opposition to international trade deals. Such agreements, Obama said, could bolster labor unions in the developing world and ensure that profits of the global economy are more evenly distributed.

“A world in which 1 percent of humanity controls as much wealth as the other 99 percent will never be stable,” Obama said.

He called for more vigilance to eliminate tax havens, fight climate change and curb the “excesses of capitalism.”

“A society that asks less of oligarchs than ordinary citizens will rot from within,” he said.

At times, Obama’s remarks were directed at his rivals in Russia and China who have in recent years forcefully pressed an alternative to his vision.

Obama dismissed suggestions by Russia that the West had played a role in the uprisings in Ukraine, insisting that the Ukrainians were fighting for universal principles and a more responsive government.

“They took to the streets because their leadership was for sale and they had no recourse,” Obama said.

He called for more work to resolve the Israel-Palestinian conflict, an unfulfilled goal of his presidency, and for more diplomacy to try to halt the bloodshed in Syria. He insisted China’s buildup in the South China Sea — which he dismissed as the “militarization of a few rocks”— could not provide a lasting solution to the territorial disputes there.

In other moments, Obama seemed to be addressing the American electorate and the deep divisions that have been revealed by the presidential election. He rejected the idea that a border wall could block the spread of disease, in the form of the Zika virus, or terrorism.

“The world is too small for us to be able to build a wall and prevent it from affecting our own societies,” Obama said. The president’s references to the futility of walls drew some chuckles in the General Assembly hall among world leaders who picked up the reference to Trump.

Near the end of his remarks and in a U.S.-sponsored refu­gee summit following his speech, Obama challenged his fellow leaders to do more to help the growing diaspora of refugees across the globe.

“We are facing a crisis of epic proportions,” Obama said. “I am here today, I called this summit because this crisis is one of the most urgent tests of our time.”

Many of the world’s refugees come from three countries — Syria, Afghanistan and Somalia — besieged by long wars with no end in sight. “The mentality that allows for violence with impunity is something we cannot excuse, and collectively we continue to make excuses,” Obama said. “We all know that what is happening in Syria, for example, is unacceptable and we are not as unified as we should be in pushing to make it stop.”

The White House said it had secured $650 million in pledges from the private sector and Obama has promised to boost the number of refugees the United States accepts next year to 110,000, a 30 percent increase from 2016.

The president concluded his U.N. General Assembly speech by returning, as he often did in the earliest days of his presidency, to his remarkable personal story. “My own family is made up of the flesh and blood and traditions and cultures and faiths from a lot of different parts of the world,” Obama said.

Obama cited his story as evidence of the existence of universal ideals and principles that are increasingly under assault in a globalizing world.

“I can best serve my own people; I can best look after my own daughters by making sure that my actions seek what is right for all people and all children,” Obama said.