DUBAI (Reuters) - Oman, which has traditionally resisted Gulf Arab states’ efforts to close ranks against Iran, has joined a Saudi-led coalition of Muslim countries to fight terrorism, Saudi and Gulf sources said on Wednesday.

The sultanate indicated its willingness to take part in the 40-country alliance in a letter to Saudi Deputy Crown Prince and Defence Minister Mohammed bin Salman, the sources said.

Although differences are rarely aired in public, Oman has long stood out among its Gulf allies. The Sultanate has worried that a wider regional confrontation between Riyadh and Tehran could threaten its own stability, and seeks to play the conciliator.

“Oman has always in the past taken positions and policies that are contrary to the Gulf positions regarding the region. This now shows the return of Oman to the Gulf consensus against Iran and its political positions,” one of the sources said.

The source said Oman’s move was a geopolitical shift in the region because “it is known that Oman has been close to Iran, the traditional enemy of Saudi Arabia and the Gulf countries”.

Prince Mohammed was expected to travel to Muscat in coming weeks to prepare for a visit by King Salman, the sources said.

One of the sources said Oman had changed its direction in the region after it realized the “lack of seriousness and of benefits” of cooperation with the Iranians.

Saudi Arabia announced the alliance in December 2015, a move welcomed by Washington which has been urging a greater regional involvement in the campaign against Islamic State militants who control swathes of territory in Iraq and Syria.

Although not explicitly aimed at countering Iran, the coalition includes neither Tehran nor its allied government in Iraq.

Oman has watched with concern as rivalry between Sunni Muslim Saudi Arabia and Shi’ite Iran has spread across the region. Riyadh and some other members of the Gulf Cooperation Council (GCC), of which Oman is a member, believe Tehran is using sectarianism to interfere in Arab countries and build its own sphere of Middle East influence.

Riyadh has backed groups opposing Iranian proxies in unrest or outright war in Syria, Lebanon, Iraq, Bahrain and Yemen, and has persuaded most of the GCC to close ranks against Tehran. Oman has sought to distance itself from that effort.

It facilitated secret U.S. talks with Tehran that led to a 2015 deal on Iran’s nuclear program which Riyadh regarded with deep suspicion.

While other GCC countries gave money and political support to Iraqi President Saddam Hussein in his 1980-88 war with Iran, Oman maintained relations with Tehran and helped to mediate a ceasefire that ended the fighting.

The Sultanate, which sits on the Strait of Hormuz, the narrow waterway between Iran and the Arabian Peninsula through which flows 40 percent of the world’s seaborne crude oil, has a history of constructive relations with Tehran, and sees itself as a mediator in a turbulent region.

Islamic State has pledged to overthrow the monarchies of the Gulf and has also mounted a series of attacks on Shi’ite Muslim mosques and security forces in Kuwait and Saudi Arabia.