As Hamas continues firing rockets and allowing other groups to fire rockets at Israel from Gaza, and as Israel responds with airstrikes, people are beginning to wonder how this round of fighting will end.

During Operation Pillar of Defense in 2012, a ceasefire was brokered with U.S. and Egyptian intervention. We can debate all day about how much Mohamed Morsi himself had to do with that, although my sense is that his role was overstated. But this time around such intervention does not seem to be coming.

The U.S. does not want to put pressure on Israel to stand down while rockets are flying against civilian targets, including heretofore untargeted locations like Jerusalem, Ben Gurion Airport, and the nuclear reactor in Dimona. It also does not want to be seen as bailing Hamas out of its self-made mess after furious criticism that U.S. backing of the PA-Hamas unity deal strengthened the terrorist group.

On the Egyptian side, the government has been doing all it can to squeeze Hamas, which is unsurprising given the prevalent hostility towards the Muslim Brotherhood. President Abdel Fattah el-Sisi has largely kept quiet on the subject of Israeli airstrikes and has sealed the border to prevent Hamas members from escaping into Egypt.

There is increasing chatter that Hamas is looking for a way out of its miscalculated escalation — and yes, every available shred of evidence indicates that this was initially escalated by Hamas and not Israel. While internal Palestinian politics is not my expertise, I am not so convinced that Hamas wants a way out just yet.

Hamas’s unpopularity and economic isolation forced it into the unity agreement with the Palestinian Authority, and one sure way to bolster its standing is by reasserting its “resistance” bona fides. Unless Israel is willing to undergo a sustained ground invasion and reoccupation of Gaza, Hamas’s military domination there vis a vis other Palestinian armed groups is not going to be threatened. Continuing to fire rockets at Israel actually ensures the group's political future.

But let’s concede that at some point both sides will be looking for a way to end the fighting. With the U.S. having no influence with Hamas and Egypt seemingly uninterested in playing mediator, who is left to step in?

The only two plausible parties are Turkey and Qatar, whose motives and standing are similar.

Both Qatar and Turkey have spent years either openly or tacitly backing Hamas at the expense of the PA, and they are also the only two countries left – not including Iran – that are still providing support and cover for the group now that Egypt and Syria are out of Hamas’s corner.

Both Qatar and Turkey have also seen their foreign policies, which seemed so ascendant a couple of short years ago, crash and burn. They are looking for a win any way they can get it.

Due to its own missteps, Turkey has found itself mired in the breakdown of the Arab Spring and particularly the fallout from the Syrian civil war. Qatar’s support of Islamist groups around the region led to Saudi Arabia, Bahrain, and the United Arab Emirates all withdrawing their ambassadors from Doha in March as a protest against Qatari meddling in their internal affairs — in other words, because of Qatar's support for various Muslim Brotherhood groups.

If either Turkey or Qatar can step in as a mediator and use its influence with Hamas to get a ceasefire deal, it will demonstrate their regional value and show that they can put their foreign policy to productive use. It could also rehabilitate both in the eyes of the other Sunni governments in the region, who view Turkey and Qatar with varying degrees of increasing suspicion.

Prime Minister Erdoğan has been relatively quiet on Gaza so far given his track record (although I should note that when I pointed this same dynamic out in 2012, it immediately backfired on me). So this time I won’t make any hard predictions about Erdoğan keeping his mouth shut. I expect him to be more vociferous at some point given the presidential election next month.

Nevertheless, I am sure that Turkey would like to play a role this time in mediating some kind of agreement. With the dearth of other candidates who have working relationships with both Israel and Hamas, this time it is actually a possibility. Turkey wants to cooperate with Israel on Mediterranean energy issues, has still been waiting for Israel to sign a reconciliation agreement, and also wants to get back into the good graces of the U.S.

Domestic politics are always at the forefront in Ankara and Erdoğan has the temperament of a ticking time bomb, so you can cue the nasty rhetoric at some point. But the fact remains that Turkey hates the fact that nobody outside of its own Foreign Ministry, the think-tank SETA, and the staff of Daily Sabah care about anything the government says on foreign policy these days, and it is desperate to reclaim some regional role.

All of these factors point to a small possibility of a U.S.-Turkey initiative at a ceasefire when both sides are ready. Let’s just hope that Erdoğan, Davutoğlu, and the rest of the AKP crew can keep their feelings about Israel enough in check to maintain some shred of credibility with Jerusalem as a potential go-between.