Anxious to keep Syria’s civil war from spiraling into even worse problems, President Barack Obama said Friday he worries about the country becoming a haven for extremists when — not if — President Bashar Assad is ousted from power.

Obama, standing side by side with Jordan’s King Abdullah II, said the international community must work together to ensure there is a credible opposition ready to step into the breach.

“Something has been broken in Syria, and it’s not going to be put back together perfectly immediately — even after Assad leaves,” Obama said. “But we can begin the process of moving it in a better direction, and having a cohesive opposition is critical to that.”

He said Assad is sure to go but there is great uncertainty about what will happen after that.

“I am very concerned about Syria becoming an enclave for extremism,” Obama said, adding that extremism thrives in chaos and failed states. He said the rest of the world has a huge stake in ensuring that a functioning Syria emerges.

“The outcome is Syria is not going to be ideal,” he acknowledged, adding that strengthening a credible opposition was crucial to minimizing the difficulties.

Eager to resolve another source of tension in the region, Obama came to Jordan from Israel, and at a joint news conference with Abdullah, said his administration is working with Congress to provide Jordan with an additional $200 million in aid this year to cope with the massive influx of refugees streaming into the country from Syria.

Abdullah said the refugee population in his country has topped 460,000 and is likely to double by the end of the year — the equivalent of 30 million refugees in the United States, he said.

Obama also said he would “keep on plugging away” in hopes of getting the Israelis and Palestinians to reach a peace agreement.

“The window of opportunity still exists, but it’s getting more and more difficult,” the president said. “The mistrust is building instead of ebbing.”

On Iran, Obama reiterated that the U.S. is open to “every option that’s available” to keep the country from developing a nuclear weapon.

He said it would be “extraordinarily dangerous” for the world if Iran does become nuclear capable, and he expressed his desire for using diplomatic means to halt Iran’s nuclear aspirations. Iran insists its nuclear program is for peaceful purposes.

“My hope and expectation is that among a menu of options, the option that involves negotiations, discussions, compromise and resolution of the problem is the one that’s exercised,” Obama said. “But as president of the United States I would never take any option off the table.”

Obama arrived in Jordan on Friday evening, the final stop on a four-day visit to the Middle East that included his first stop in Israel as president.

He began his visit to Amman with an apology.

“I apologize for the delay,” Obama told Abdullah after arriving about an hour behind schedule. “We ended up having a dust storm.”

The two leaders headed to dinner after their news conference. On Saturday, Obama planned several hours of sightseeing, including a tour of the fabled ancient city of Petra, before the return trip to Washington.

Before leaving Israel, Obama paid his respects to the nation’s heroes and to victims of the Holocaust. He also solemnly reaffirmed the Jewish state’s right to exist.

Accompanied by Netanyahu and President Shimon Peres, Obama laid wreaths at the graves of Theodor Herzl, the founder of modern Zionism who died in 1904 before realizing his dream of a Jewish homeland, and former Israeli Prime Minister Yitzhak Rabin, who was assassinated in 1995.