Oman has joined a Saudi-led coalition of Muslim countries to fight terrorism, Saudi and Gulf sources have said, in a sign of a possible geopolitical shift among the Gulf states.

Oman 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, sources told Reuters on Thursday.

Although differences are rarely aired in public, Oman had 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 has often sought to play a mediation role.

"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".

Saudi Arabia's Prince Mohammed is expected to travel to Muscat in the coming weeks in preparation for a visit by King Salman, the sources said.

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

Saudi Arabia annnounced the alliance in December 2015, a move welcomed by Washington, which had urged greater regional involvement in the campaign against Islamic State militants.

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

Oman has watched with concern as rivalry between Sunni Muslim Saudi Arabia and Shia Iran has spread across the region.

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 previously sought to distance itself from that effort.

It facilitated secret US talks with Tehran that led to a 2015 deal on Iran's nuclear programme which Riyadh regarded with deep suspicion.

Oman is also the only Gulf state not currently involved in a bombing campaign in Yemen aimed at routing Houthi rebels, who Saudi Arabia says are direct proxies of Iran.

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 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.

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