And it will require leaders on both sides of the generations-long dispute to take political risks for the sake of peace and prosperity, he said.
But first, Mr Obama said, a temporary ceasefire in place in the Gaza Strip must hold without being violated before it expires tomorrow.
Mr Obama was responding to questions about ongoing negotiations in Cairo over how to maintain the tentative truce between Israel and the militant group Hamas that controls the Gaza Strip.
The president said Israel deserves to defend itself from a barrage of rockets from Gaza, and terror tunnels that Hamas has dug into Israel.
At the same time, however, he said the Palestinian people in Gaza need to have some confidence that they will be able to rebuild their communities, pursue prosperity and not feel walled off from the rest of the world.
To achieve both goals, "there are formulas available, but they are going to require risks on the part of political leaders, they will require a slow rebuilding of trust, which is obviously very difficult in the aftermath of the kind of violence that we have seen," Mr Obama said.
"So I don't think we get there right away."
He twice repeated that "I have no sympathy for Hamas," which both the US and Israel consider a terrorist organisation.
Nearly 1,900 Palestinians have been killed in the latest outbreak of fighting between Israel and Hamas that began on July 8. Sixty-four Israeli soldiers and three civilians inside Israel have also been killed.
Mr Obama also said he has "great sympathy" for the Palestinian Authority, which is based in the West Bank city of Ramallah and is led by President Mahmoud Abbas, who over the last year participated in what was an ultimately failed push for enduring peace with Israel.
He called Mr Abbas "sincere in his desire for peace," but said the Palestinian Authority appears to have been weakened by the violence and failure for a long-term resolution with Israel.
He said the Palestinian Authority has shown itself to be responsible, and has recognised the state of Israel, as part of its desire for a solution that would also give international recognition to a state of Palestine.
"The population in the West Bank may also have lost confidence or hope on how to move forward," Mr Obama said. "We have to rebuild on that as well."
The peace process fell apart last April after nearly nine months of negotiations, in part after Mr Abbas and Hamas agreed to build a new government together and give the Palestinian people a unified leadership for the first time in years.
Israel angrily shelved the negotiations, saying it would not deal with a government that included Hamas.
Negotiators from Israel were meeting a Palestinian delegation in Cairo for talks on extending the temporary ceasefire and trying to resolve underlying issues to broker a more lasting truce.
Officials from the US, the United Nations and Middle East nations were helping foster the discussions, which began with both sides taking hardline positions.