AMMAN, Jordan — 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.

Obama, 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 60 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.”