Qatar is set to host Gaza ceasefire talks on Thursday, seeking a so-far elusive agreement that the United States hopes would stop Iran striking Israel and avert a wider war.

US, Qatari and Egyptian mediators have invited Israel and Hamas for negotiations aimed at ending fighting that the Hamas-run Gaza health ministry says has killed nearly 40,000 people in the Palestinian territory.

The talks will be held in the Qatari capital Doha, a source close to Hamas and a second source close to the negotiations said Wednesday.

According to a US source familiar with the Doha meeting, CIA director William Burns is scheduled to take part.

Israel confirmed it would attend, though it remained unclear if Hamas, whose October 7 attack on Israel triggered the war, planned to participate.

Mediation efforts have repeatedly stalled since a week-long ceasefire in November -- the only pause so far in the war -- when dozens of hostages were released by militants in exchange for Palestinian prisoners held in Israeli jails.

A Hamas official said the Islamist movement was "continuing its consultations with the mediators", after demanding the implementation of a proposal that US President Joe Biden laid out on May 31, instead of holding more talks.

The phased plan would start with an initial six-week "complete ceasefire", the release of some hostages held in Gaza and a "surge" in humanitarian aid entering the besieged territory as the warring sides negotiate "a permanent end to hostilities", Biden said at the time.

US Secretary of State Antony Blinken told several Middle Eastern counterparts in recent days that "this ceasefire deal is of vital importance, that we need to do everything we can to get it done, and that escalation is in no one's interest", State Department spokesman Vedant Patel said on Wednesday.

The latest mediation push comes as regional tensions have soared following the July 31 killing of Hamas political leader and truce negotiator Ismail Haniyeh during a visit to Tehran.

Iran and its allies blamed Israel, which has not claimed responsibility for the attack that Tehran and armed groups it backs in the region have vowed to avenge, raising fears of a wider conflict more than 10 months into the Israel-Hamas war in Gaza.

- 'No one knows' -

Western leaders have urged Tehran to avoid attacking Israel over Haniyeh's killing, which came hours after an Israeli strike in Beirut killed a senior commander of Hamas ally Hezbollah, the powerful Iran-backed militant group in Lebanon.

Asked whether a ceasefire agreement in Gaza could stave off a feared Iranian attack on Israel, Biden said: "That's my expectation".

Iranian foreign ministry spokesman Nasser Kanani said Tehran rejects Western calls "to take no deterrent action against a regime which has violated its sovereignty", referring to Israel.

Last week the Iranian mission to the United Nations expressed "hope" that the retaliation would not be "to the detriment of the potential ceasefire" in Gaza.

A spokesman for Israeli Prime Minister Benjamin Netanyahu told AFP that the heads of the Mossad spy agency and Shin Bet secret service would attend the Doha talks.

State Department spokesman Patel earlier told reporters that Qatar was "working to ensure that there is Hamas representation as well".

Qatar's Prime Minister Sheikh Mohammed bin Abdulrahman Al-Thani discussed in a phone call Wednesday with Blinken "joint mediation efforts to end the war" and "the need for de-escalation", the Qatari foreign ministry said.

Both men said "no party in the region should take actions that would undermine efforts to reach a deal," according to a US State Department readout of the call.

Israeli President Isaac Herzog said on social media platform X that the country remained on "high alert" over "the hate-filled threats of the Iranian regime and its terrorist proxies".

- 'We are all suffering' -

Hamas's unprecedented October 7 attack on southern Israel resulted in the deaths of 1,198 people, mostly civilians, according to an AFP tally of Israeli official figures.

Militants also seized 251 people, 111 of whom are still held captive in Gaza, including 39 the military says are dead.

Israel's retaliatory military offensive in Gaza has killed at least 39,965 people, according to the territory's health ministry, which does not provide a breakdown of civilian and militant deaths.

The Israeli military said it carried out dozens of air strikes in the past 24 hours, and Palestinian civil defence rescuers reported artillery shelling and aerial attacks across the Gaza Strip.

In Lebanon, the health ministry reported two killed in separate Israeli strikes, the latest in near-daily cross-border violence throughout the Gaza war. Hezbollah said two of its fighters were killed.

The Israeli military said its air force had "struck Hezbollah military structures".

Numerous governments have issued advisories against travel to Lebanon and prepared contingency plans to evacuate their nationals from the region if full-scale war breaks out.

The United States has deployed an aircraft carrier strike group and a guided missile submarine to the region in support of Israel.

As part of de-escalation efforts, French Foreign Minister Stephane Sejourne is set to visit Beirut Thursday, diplomatic sources said, on the heels of a visit Wednesday by US envoy Amos Hochstein.

With negotiators planning to meet, Palestinian Ibrahim Makhamer told AFP in central Gaza's Deir al-Balah: "We hope for the end of the war."

"We are all suffering," said Makhamer, denouncing "a policy of starvation" and shortages of medical supplies in the territory, where the vast majority of its 2.4 million people have been displaced at least once by the war.