The rival Palestinian factions agreed Wednesday on a reconciliation deal that would unite Hamas and Fatah amid sputtering peace talks between Israel and the Fatah-led Palestinian Authority.

The agreement calls for a unity government within weeks, the BBC reports, seven years after the two factions violently split, with Hamas retaining control of the Gaza Strip and the Western-backed Palestinian Authority ruling in the West Bank.

Earlier Wednesday, Israeli Prime Minister Benjamin Netanyahu warned Palestinian President Mahmoud Abbas that he would have to choose between peace with Israel or with Hamas, an Islamist militant group that rejects peace with Israel, Reuters reports.

The U.S.-backed peace talks have stalled, with both sides defying terms of the negotiations ahead of the impending April 29 deadline that negotiators are trying to extend.

The agreement reached Wednesday calls for general elections within six months of a vote of confidence by the Palestinian parliament, according to BBC. But past deals have fallen through before being implemented, including an Egyptian-brokered deal that fell apart over power sharing and relations with Israel.

[BBC]

Write to Noah Rayman at noah.rayman@time.com.