RAMALLAH, West Bank --

I had held off coming to Israel, hoping the situation in Gaza would clarify - not in terms of what's happening, but how it might end in a stable way. Being here now, it is clear to me that there is a way this cruel little war could not only be stopped, but stopped in a way that the moderates in the region, who have been so much on the run, could gain the initiative. But - and here is where some flight from reality is required to be hopeful - developing something that decent out of this war will demand a level of leadership from the key parties that has simply never been manifested by any of them. This is a generation of Arab, Palestinian and Israeli leaders who are experts at building tunnels and walls. None of them ever took the course on bridges and gates.

I happened to be in the U.S. Embassy in Tel Aviv late Friday when air raid sirens went off as a result of a Hamas rocket being aimed at the city. Standing in the embassy basement, I had a moment of quiet to think about how much creativity lately has gone into war-making around here and how little into peacemaking. Israel has developed a rocket interceptor system, the Iron Dome, that can immediately calculate whether a Hamas rocket launched in Gaza will hit a built-up area in Israel - and needs to be intercepted - or will fall into the sea, farm fields or desert and can be ignored and, therefore, avoids the $50,000 cost of an interceptor. The system is not only smart; it's frugal. If this Israeli government had applied the same ingenuity to trying to forge a deal with the moderate Palestinian Authority in the West Bank, Hamas would be so much more globally isolated today - not Israel.

Meanwhile, Hamas, using picks, shovels and little drills, developed an underground maze of tunnels in Gaza, under Israel's nose, with branches into Israel. If Hamas - which has brought only ruin to the people of Gaza, even in times of quiet - had applied that same ingenuity to building above ground, it could have created the biggest contracting company in the Arab world by now, and the most schools.

Every war here ends eventually, though, and, when this one does, I don't think we'll be going back to the status quo ante. Even before a stable cease-fire occurs, Israeli and Palestinian Authority officials have been discussing the principles of a lasting deal for Gaza. Given the fact that Egypt, Jordan, Saudi Arabia and the United Arab Emirates hate Hamas - because of its ties to the Muslim Brotherhood - as much as Israel, the potential exists for a Gaza deal that would truly align moderate Arabs, Palestinians and Israel. But it won't come cheap. In fact, it will require Israel, Hamas and the U.S. to throw out all the old rules about who doesn't talk to whom.

Here's why: Hamas has been a formidable foe for Israel, and it is unlikely to stop this war without some agreement to end the Israeli-Egyptian blockade of Gaza. Israel is not likely to stop this war without having rooted out most of the Hamas tunnels and put in place a regime that will largely demilitarize Gaza and prevent the import of more rockets.

Since neither Israel nor Egypt wants to govern Gaza, the only chance these goals have of being implemented is if the moderate Palestinian Authority here in Ramallah, led by President Mahmoud Abbas, is invited back into Gaza (from which it was evicted by Hamas in 2007). And, as one of Abbas' senior advisers, Yasser Abed Rabbo, explained to me, the only way that can happen is if the Palestinians form a national unity government, including Hamas, and if Israel agrees to resume negotiations with this government about ending the West Bank occupation.

The Palestinian Authority has no intention of becoming Israel's policeman in the West Bank and in Gaza for free. "To hell with that," Abed Rabbo said. If the Palestinian Authority is going to come back in as the game-changer, it will be as the head of a Palestinian national unity government, with Hamas and Islamic Jihad inside, that would negotiate with Israel, he said. If Hamas and Israel want to end this war with some of their gains intact, they will both have to cede something to the Palestinian Authority.

No one should expect, Abed Rabbo said, that "we, 'the stupid moderates,' will sit there and play a game in favor of Hamas or Israel and not get anything out of it, and we will go back to the same old negotiations where" Israel just says "blah blah blah." If we do that again, "my kids will throw me out of my house."

"We should have a serious Palestinian reconciliation and then go to the world and say, 'OK, Gaza will behave as a peaceful place, under the leadership of a united Palestinian front, but, (Egypt), you open your gates, and, Israel, you open your gates,'" Abed Rabbo said. The moderate Arab states would then contribute the rebuilding funds.

Unless Hamas or Israel totally defeats the other -- unlikely -- it is hard for me to see how either side will get out of this war the lasting gains they want without conceding something politically. Israel will have to negotiate in earnest about a withdrawal from the West Bank, and Hamas will have to serve in a Palestinian unity government and forgo violence. I can tell you 17 reasons that this won't happen. I just can't think of one other stable way out.

Thomas Friedman is a syndicated columnist with The New York Times.