CAIRO — After a decade of hostility and recrimination, the two main Palestinian factions came together in Cairo on Thursday to sign a reconciliation deal that holds out the tantalizing prospect of a united Palestinian front.

Hopes for the agreement, signed under the watchful eye of Egyptian intelligence, were tempered by the knowledge that many previous Palestinian initiatives have failed. Yet there is optimism that this time may be different, partly because the stakes are so much higher.

For the two million Palestinians of Gaza, trapped in a tiny coastal strip that is frequently compared to an open-air prison, the Cairo deal offered a potential respite from their lives of dire shortages of electricity and lifesaving medicine, as well as a chance to travel to the outside world.

For the Palestinian leadership, it held out the prospect of negotiating with Israel with a single voice, even as it forced the divided territory’s most radical militants to make painful concessions that acknowledged their own failure to advance their cause.