The courtship of Hamas between rivals Iran and Qatar has been one of the Middle East's intriguing subplots of the Arab Spring. The bloodshed in Gaza has now sharpened their competition for influence with the Palestinian militant group and the direction it takes in the future.
Qatar has sought to use its vast wealth to win over Hamas with investments and humanitarian aid and encouraging Arab partners to do the same — part of the hyper-rich U.S. allied nation's broader campaign to bring under its wing Islamist movements that have risen to power in the region the past two years. Qatar's influence with Hamas could edge it away from armed action toward diplomacy.
Iran, meanwhile, is invigorating its longtime role as the builder of the rocket arsenal for Hamas' military wing.
For Hamas, there are benefits in both directions — and it's happy to play both sides. During a celebration rally in Gaza City after an Egyptian-mediated cease-fire came into place ending fighting between Israel and Hamas, Gazans wildly waved flags of Qatar, along with those of Egypt and Turkey, in gratitude for those countries' diplomatic support.
At the same time, Hamas' leader-in-exile Khaled Mashaal, who is based out of Qatar, gave a very public thanks to Iran for standing by Gaza with crucial military assistance. Fighters in Gaza also hailed the new reach of their arsenal, with Iranian-designed Fajr-5 rattling Israel by reaching the outskirts of Tel Aviv and Jerusalem.
Visiting the Syrian capital Damascus on Friday, Iran's parliament speaker Ali Larijani, who is close to the country's supreme leader, promised leaders of Palestinian militant groups that his country would continue to boost "the resistance's capabilities in confronting the Zionist arrogance and aggression," according to Palestinian official Khaled Abdul-Hamid, who attended the meeting.
The reminder of Hamas' reliance on Iran for weapons could help smooth a relationship that has been running through a rough patch because of the civil war in Syria, Iran's top ally.
Embarrassed by the Syrian regime's crackdown on a mainly Sunni Muslim uprising, Hamas leaders based in Damascus for years broke with Syria and left for Qatar and Egypt. Though Iran continued to send weapons to Hamas, the break undermined the "Axis of Resistance" grouping Syria, Hezbollah and Hamas that Iran has assembled in the Arab world.
It's doubtful Iran can fully reclaim its position as the main big brother for Hamas. But Tehran's image is certain to receive some lingering boost in Gaza.
For Hamas, hyper-rich Qatar is a political and economic lifeline, a key part of the militant group's attempts to bolster its ties with the Western-backed Gulf states in efforts gain more international legitimacy. Last month, Qatar's emir became the first head of state to visit the Gaza Strip since Hamas took control five years ago. The Gulf state pledged nearly $500 million in aid and a song called "Thank you, Qatar" played on Gaza radio and TV as the emir was given a hero's welcome.
During the heat of the Gaza battle the past week, Qatar's prime minister gave a blistering dressing down to the Arab League during an emergency meeting, saying Arab nations had to do more to fight Gaza's poverty and isolation than just pass resolutions.
"We can't give hope without delivering," Sheik Hamad Bin Jassem Al Thani told the gathering last week in Cairo.
Two days after his outburst at the Arab League meeting in Cairo, Sheik Hamad suggested that his country would be willing to open dialogue with Israel on a long-term Gaza truce if it leads to lifting the blockade. The Arab Spring, he added, has made Israel feel more vulnerable, but also perhaps more ready to make deals.
"We need to talk with everyone to reach a comprehensive peace," he told CNN on Monday.
For Qatar, the outreach to Gaza also is part of far wider ambitions to become a major policy-shaper in the Middle East. The tiny Gulf nation has emerged as a strong backer of the Muslim Brotherhood, which has risen to power in Tunisia and Egypt after the fall of those countries' autocratic leaders in early 2011.
In February, Qatar brokered talks between Hamas' Mashaal and his longtime rival, internationally backed Palestinian President Mahmoud Abbas.
Qatar has also sought to influence Syria's rebels. This month, it hosted Syrian opposition groups in a breakthrough effort to unite rebel factions under one coalition, which has opened the way for greater international recognition and promises of aid. Qatar had led calls to supply Syrian rebels with heavy weapons to counter air and tank attacks by Bashar Assad's forces. Qatar also was a key backer of the Libyan uprising.
On Thursday, Qatar also invited the newly formed Syrian opposition coalition to appoint its ambassador to the Gulf state, the Qatari news agency reported.
Salman Shaikh, director of The Brookings Doha Center in Qatar, said it's not a matter of "having to go all for Iran or all for Qatar.'
"What Qatar is trying to do is change the reality. They are trying to blaze a trail that will weaken the international isolation of Gaza from the Israeli blockade," he said.
Qatar has so far stopped short of offering any kind of military support for Gaza to avoid a rift with Washington, Israel's most powerful ally.
Iran takes a very different view.
Officials in Tehran boasted this week about its longtime arms support for Hamas militants — part of Iran's bookend strategy to equip anti-Israel factions in Gaza and Hezbollah in Lebanon on Israel's northern border.
Gen. Mohammad Ali Jafari, the head of the Revolutionary Guard, said Iran supplied fighters in Gaza with the technology to "quickly" produce the Fajr-5 missiles. The statement fits with previous Iranian denials that it is not directly sending missiles to Gaza, but suggests close coordination on construction and movement of supplies, presumably through the smugglers' tunnels linking Gaza and Egypt.
The Gaza fighting, at the least, bought Iran some restored street credibility as its image was battered by its backing for the regime of Syrian President Bashar Assad.
"The war with Israel reminded Hamas that Israel is the main issue not Syria," said Heshmatollah Falahatpisheh, a professor in politics in Tehran's Allameh University.
But Hamid Reza Shokouhi, editor of Iran's independent Mardomsalari daily, said the bump in Iran's popularity with Gazans could be only "short-term." He questioned whether Iran could sustain its influence in Gaza against the almost unlimited resources of Qatar and its Gulf partners.
Iran's Foreign Ministry and a parliamentary committee have applied for permission to visit Gaza in the coming weeks via the border crossing with Egypt, said Hasan Qashqavi, deputy foreign minister in charge of consular affairs.
Qatar's prime minister said the competition for influence is Gaza only likely to intensify as other nations such as Turkey and Egypt reach out.
"We are not trying to take Hamas from anybody else, from Iran or others," he said in the CNN interview. "Hamas, they have to decide for themselves. I think they are pretty mature to decide for themselves."
Associated Press writer Nasser Karimi in Tehran, Iran, contributed to this report.