ISTANBUL — It was nearly two years ago when Iran and Saudi Arabia cut diplomatic ties, worsening an already tense rivalry that has fueled conflicts across the Middle East. But this year, a rare bright spot in their relations has stirred hope of a possible detente.
More than 80,000 Iranian pilgrims are now in Saudi Arabia to perform the hajj, the annual pilgrimage to Islam's holiest sites, after they were barred last year from making the trip. The hajj, one of the five pillars of Islam, is obligatory for all able-bodied Muslims, and sees roughly 2 million worshipers descend on Mecca and Medina each year.
The return of Iranian pilgrims followed painstaking negotiations between officials from the two countries, after relations deteriorated sharply over the past two years.
Those discussions probably "helped ease some initial tension," said Reza H. Akbari, who researches Iranian politics at the Institute for War and Peace Reporting.
This week, Iranian President Hassan Rouhani said that if all goes smoothly, the pilgrimage could set the stage for further talks. Foreign Minister Mohammad Javad Zarif also said last month that Iran and Saudi Arabia were preparing to exchange diplomatic visits.
"The visas have been issued for both sides to make this trip," he told a local news outlet.
The friendlier cooperation comes even as the two countries fight proxy wars in Yemen and Syria, and continue to compete for influence from Afghanistan to Bahrain.
While the rivalry is geopolitical, it also is colored by the battle between competing branches of Islam.
For Iran, the strict version of Sunni Islam promoted by Saudi rulers has helped inspire Islamist militants around the globe. Saudi Arabia, in turn, has viewed Iran as a threat since the Islamic revolution in 1979. The Saudi government has encouraged anti-Shiite rhetoric both at home and abroad.
Tensions rose this spring when President Trump, speaking from Saudi Arabia, called on Muslim nations to isolate Iran. Later, Iran blamed Saudi Arabia for an attack on the nation's parliament by Islamic State militants. The attackers, all of whom were killed, were identified by Iran as local ethnic Kurds, the majority of whom are Sunni.
But as the world's largest gathering of Muslims, the hajj also has served as a battleground for the archrivals, which both claim to lead the global community of Muslims.
In 2015, Iran openly challenged Saudi control of Muslim holy sites after a stampede in Mecca killed more than 2,400 people, including at least 464 Iranians, according to a count from the Associated Press. Throngs of worshipers crowd the holy sites to reenact steps taken by the prophet Muhammad.
Iran's supreme leader, Ayatollah Ali Khamenei, accused the Saudi leadership of "murder" and urged Muslims to "fundamentally reconsider" allowing Saudi Arabia to continue to oversee the hajj.
Several months after the stampede, in January 2016, Saudi Arabia executed a Shiite dissident cleric, Nimr al-Nimr, and Iranian protesters attacked its embassy in Tehran. Saudi Arabia and several other countries then severed ties with Iran, and the spat spilled over into negotiations over the hajj, leaving Iranians unable to attend the pilgrimage.
Iran has consistently tried to undermine the Saudis "by questioning their ability to ensure the safety and security of pilgrims," Akbari said.
But the "hajj has been used as a political lever by both sides to exert or ease tensions as needed," he said. "It is a powerful tool that sends a clear signal to the entire region about Saudi Arabia and Iran's relationship status."
This year, Khamenei refrained from condemning the Saudis, instead calling on Muslims to focus on enemies such as Israel and the United States.
But others warned against viewing the pilgrimage as a sign of thawing relations between the two sides.
In the past, the two powers "have hurtled insults at each other, engaged in diplomatic footsie and then repeated this cycle," said Behnam Ben Taleblu, Iran expert at the Foundation for the Defense of Democracies.
"Muslim unity during the hajj season is a potent religious symbol," he said. "But it does not do away with the other factors driving their competition for Muslim hearts, minds and battlefields across the Middle East."