(CNN) -- The Sultanate of Oman is a rarity in the diplomatic world: It enjoys "cordial" relations with both the United States and Iran. And once again, it is closely involved in trying to help win the freedom of Americans held in Iran.
In 2010, Omani sources paid $500,000 bail to help win the release of American hiker Sarah Shourd, who with her fiancé Shane Bauer and Josh Fattal was detained in 2009 after allegedly straying across an unmarked stretch of the Iran-Iraq border. The Omanis are now involved in brokering the release of Bauer and Fattal.
Sultan Qaboos, who has ruled Oman for more than 40 years, has gone to great lengths to strike a balance in relations with Iran -- Oman's neighbor across the Strait of Hormuz -- and his traditional allies in the west, especially the UK and U.S.
According to a U.S. diplomatic cable from December 2009, the Omani foreign minister, Yusuf bin Alawi, offered to set up discreet talks between the United States and Iran.
"When thanked by the Ambassador for Oman's ongoing advice to Iran to work with the West, YbA offered Oman as both an organizer and a venue for any meeting the U.S. would want with Iran - if kept quiet," the cable said. Anything to avoid "heated atmospherics," in the words of another Omani official.
The same cable showed that the Omanis are more relaxed than others in the Gulf about Iran's nuclear ambitions, with bin Alawi telling the U.S. ambassador that "even if Iran developed nuclear weapons, this action would not destabilize the region, a point vigorously countered by the Ambassador."
The open door to Tehran is part dictated by geographical necessity but also helps Oman follow a foreign policy independent of its giant neighbor, Saudi Arabia, the most powerful member of the Gulf Cooperation Council. Qatar has a similar approach, much to the annoyance of the Saudis.
Theodore Karasik of the Institute of Near East and Gulf Military Analysis says that "from the Omani point of view, they see the other GCC states as being 'over there' behind the mountains; we're in front of the mountains. That separates them from the rest of what the GCC states are thinking. That's why they feel that they can have a special relationship with Iran."
Oman is separated from other Gulf states by the long and largely impenetrable Al Hajar mountain range. At its northern end, the range gives way to the Persian Gulf and the narrow Strait of Hormuz, where the territory of Oman and Iran is just 18 miles apart.
More than 15 million barrels of oil (40% of the world's total output) pass through the Strait every day, which makes it a security headache for both countries. They have a joint military commission dealing with security in the shipping lanes (which are mostly in Omani waters) and smuggling.
Omani sources say smuggling gangs use fishing boats to traffic Afghan and Pakistani migrants, as well as weapons and drugs across the Strait from Iran to Oman.
Not that Qaboos feels any ideological affinity with the Islamic regime across the water. A friend of the Shah of Iran's, he is said to have been deeply troubled by the 1979 revolution. The sultan, who has no designated successor, is by all accounts an erudite figure equally at home in traditional Arab and modern Western society.
One dispatch from 2008 prepared for a visiting U.S. envoy said, "You will find the Sultan an engaging interlocutor. He is an intellectual whose interests range from sustainable agriculture to classical music."
He is also a pragmatist who has personally steered Oman's foreign policy. As one U.S. diplomatic cable from the Embassy in Oman puts it, "A common saying in the region is that Oman is a friend to all and the enemy of none."
Qaboos visited Iran in 2009 (for the first time since 1974), signing a number of agreements while urging Ayatollah Khamenei to engage in dialogue with the U.S. over Iran's nuclear program and other disputes.
A U.S. diplomatic cable from 2010 published by WikiLeaks described Oman's perspective this way: "Although they do not find the threat imminent, Iran is Oman's number one strategic threat; however, the GoO fundamentally believes the threat can be mitigated through careful management of the relationship."
One example of that management is the recent establishment of a joint Oman-Iran investment company. Given its proximity, Iran should be a natural trading partner for Oman, but it can't offer the help Oman needs in developing its mineral wealth and diversifying its economy.
For those goals, Qaboos looks west. Oman has a free trade agreement with the U.S., allowing American companies to establish businesses there. It also buys U.S. military hardware, such as F-16s.
Even so, Omani authorities are careful not to antagonize public opinion by too close an association with the United States. The Omanis were quick to reject reports last year that they would host U.S. Patriot anti-missile batteries, with a senior official stressing that Oman "does not allow its territory to be used to carry out any military operations against any country in the region."
Similarly, both in private and public, Oman has been highly critical of U.S. policy toward Israel, repeatedly appealing for Washington to exert greater pressure on Israel in negotiations with the Palestinians.
One diplomat in the region likens Oman's role to that of the Swiss or Swedes elsewhere: avoid making enemies but avoid entangling alliances.