– Former President Barack Obama, stressing the importance of the Paris climate agreement, criticized President Donald Trump for taking the United States out of the deal.

Trump said last month he would withdraw from the agreement and seek to negotiate a better deal.

“In Paris, we came together around the most ambitious agreement in history to fight climate change,” Obama said Saturday in a speech at the opening of the Fourth Congress of the Indonesian Diaspora in Jakarta. He said it was “an agreement that even with the temporary absence of American leadership will still give our children a fighting chance.”

“The challenges of our times, whether it’s economic inequality, changing climate, terrorism, mass migration; these are really challenges and we’re going to have to confront them together,” he said.

Obama, who has been vacationing in Indonesia and on Friday met with President Joko Widodo, also warned in remarks Saturday against rising sectarian politics around the world, as well as growing discrimination based on race and ­ethnicity.

“There are going to be some big decisions to make about Indonesia and about the United States and about the world in the years to come,” he said. “It’s been clear for a while that the world is at a crossroads, at an inflection point.”

He said in Jakarta there had been “enormous progress” that occurred “in part because of the stability that the United States helped support here in the Asia Pacific.”

But Obama said there are also challenges, and that globalization and technology had created problems and “shifts in the foundations of societies” and in politics both in developing and developed countries.

“The world is more prosperous than ever before, but this has also brought significant changes that are dangerous.

“We start seeing a rise in sectarian politics, we start seeing a rise in an aggressive kind of nationalism, we start seeing both in developed and developing countries an increased resentment about minority groups and the bad treatment of people who don’t look like us or practice the same faith as us.

“We start seeing discrimination against people based on race or ethnicity or religion.” Those threats must be confronted, Obama said.

Obama, who spent four years in Indonesia as a child, met with Widodo, known as Jokowi, at Bogor on the outskirts of the capital.

“I always found Jokowi to be a man of quiet but firm integrity and somebody who sincerely wants what’s right by all Indonesians,” he said.