The official, who visits Iran often, told Al-Monitor, “There were plans for Khaled Meshaal to visit Tehran, [but] on several occasions the visits were canceled because of the uncertainty on our side that it would go as planned.”

A senior Hamas official who spoke to Al-Monitor in Beirut on condition of anonymity said, “We’ve never taken sides, but we have our say on what’s happening. Iran is a friend. It was once a very close friend, and we don’t forget that. But today there are efforts to normalize ties once again. This is facing some hurdles from both sides .”

Yet Hamas is trying to keep minimal links with its former financiers and backers, mainly Iran.

On one side there’s the ideological link with Turkey, Qatar and the Muslim Brotherhood; on the other side, a political financial link with Iran, Syria and Hezbollah. Both blocs are on opposite sides today in both Yemen and Syria’s ongoing crises. They have different point of views on where the region should head and who should lead the transitional period.

Who wants to be in Hamas’ shoes? Probably no one in the greater Middle East, where the Palestinian group is trapped between two major blocs who used to have much in common prior to the Arab Spring .

Meshaal, head of Hamas’ political bureau, is concerned he won’t be allowed to meet the supreme leader of Iran, Al-Monitor learned, as a trip to Tehran would be useless without a meeting with Ayatollah Ali Khamenei.

“There’s a kind of mistrust between Meshaal and the Iranians,” the anonymous source told Al-Monitor. “There’s a need to rebuild this relationship. Other leaders from Hamas are visiting Tehran every now and then, and this is another indication the relationship isn’t at its worst.”

“There’s a wing in Iran that doesn’t want any relation with Hamas, and there’s a wing in Hamas that doesn’t want these ties to be boosted,” said the senior Hamas official. “But I can ensure that both Col. Qasem Soleimani, head of the Quds Force, and Sayyed Hassan Nasrallah, Hezbollah’s secretary-general, are pushing toward opening a new chapter and restoring good ties.”

An Iranian official source told Al-Monitor that relations with Hamas are always a priority for Tehran. “We will always support the resistance,” he said. “This was our stance from the first day of the revolution; this will be our stance after the nuclear deal. Palestine is our priority, and we won’t ever change.

“It’s a strategic bond with the Palestinian resistance, not tactical” he added. “There are some differences with the political leadership of Hamas over the position from Syria, but this isn’t going to affect the relationship with the resistance and the armed wing.”

The Hamas official said the Iranians were insisting at the beginning that Meshaal should lead any delegation visiting Tehran.

“Meshaal wanted guarantees he’ll meet the [supreme leader]. He wasn’t given any. Then we agreed with the Iranians on a delegation led by Mousa Abu Marzouk, Mahmoud al-Zahar and Mohammed Nasr — this was until Meshaal visited Saudi Arabia on July 16.”

Iran’s Fars News Agency published a report about the Hamas visit that was deleted after only a few hours. “We called the Iranians and told them to see what their news outlets are publishing,” said the Hamas source. “They were trying to involve us in a fabricated scenario that accused our leadership of discussing with the Saudis sending fighters to help in Yemen, and this is not true,” he said.

The source elaborated that the visit to Saudi Arabia in question came after Hamas attempted several times to visit the kingdom in order to talk about the case of eight Hamas officials who were arrested by Saudi authorities. Among the detainees was Abou Aref, head of the Hamas Shura Council.

The official Hamas source continued, “There were several attempts by leaders in the region to help secure an appointment for Hamas leaders in Saudi Arabia. Turkey’s President Recep Tayyip Erdogan tried and failed. So did Sheikh Tamim of Qatar; even Mahathir Mohamad of Malaysia didn’t succeed.”

At that point, Meshaal asked for a visa to visit the holy places in Mecca and Medina [for an Umrah pilgrimage], which he was granted on July 13, the 26th day of Ramadan. “He went with a few members of the group’s political bureau, and they were warned by a representative from Saudi intelligence not to contact anyone,” the source said.

Al-Monitor learned Meshaal decided to take the risk and contact some of his friends in Riyadh, who helped him take part in the Eid prayers at the king’s palace. After the prayers, Meshaal and his delegation were able to see the king, the crown prince and the deputy crown prince for a few minutes. Meshaal used the brief time to raise his case, and he was able to secure an appointment with the deputy crown prince, Mohammed bin Salman. Meshaal and his team went to the appointment, yet they had to wait almost six hours until the Saudi prince appeared, and they only met for 20 minutes.

During that meeting, Meshaal asked for bin Salman’s help in releasing the Hamas top leader and his aides. Bin Salman was clear that no other issues could be discussed on this occasion; they only heard from him that Saudi Arabia’s main mandate in the region is to face Iran’s “hegemony” and that Iran will do whatever possible to win that confrontation.

“As Meshaal and the delegation came out, Abou Aref and his companions were released,” the Hamas official source told Al-Monitor. “This is how the visit ended. Nothing big happened. It was only about these people, to get them released. The Iranians met us after the Saudi visit, and since then, they’ve been insisting there’ll be no visit to Tehran without Meshaal heading the delegation.”