When Saudi King Salman emerged earlier this week from a Boeing 747 that is bigger than Air Force One onto a specially made escalator and descended onto the tarmac of the government VIP terminal in Jakarta, the irritations that have dogged relations between the kingdom and the world’s largest Muslim majority all but evaporated.

Gone – at least for now – were the steady feed of stories of mistreated domestic workers or of injured hajj pilgrims yet to receive compensation. Instead, when the custodian of Islam’s holiest mosques in Mecca and Medina slipped into one of the two Mercedes limousines he had flown by Hercules transport aircraft ahead of his arrival on Wednesday, what fed 250 million or so Indonesians was spectacle.

“This is the guy who can, at any time he wants, travel to Mecca and step inside the Kaabah,” said Asia Foundation’s Indonesia representative Sandra Hamid, referring to the black tiled building at the centre of the Al-Masjid al-Haram to which Muslim faithful anywhere in the world turn towards to pray. “People are amazed. It’s like a fairytale.”

The real agenda for Saudi king’s tour of China, Malaysia, Indonesia

Just as well. The Saudi king’s visit, the first since a brief stop here by his predecessor, King Faisal in 1970, comes as plummeting oil prices and the re-emergence of arch rival, Iran, challenge his kingdom’s sway. King Salman is betting he can shore up his clout amid shifting geopolitical allegiances.

“The whole visit is a signal that Middle East countries are waking up to the strategic importance of Indonesia,” said Yenny Wahid, director of the Wahid Institute in Jakarta, a political think tank. “Indonesia is usually associated with domestic workers who are considered almost lower caste.”

While oil prices have been soft for some time now, what’s focused Saudi minds is that the prices are ebbing as Iran’s fortunes begin to flow.

The plight of Chinese Indonesians: distrusted in Jakarta, forgotten in China

Indonesian President Joko Widodo, known by all here as Jokowi, made an official visit to Iran in mid-December to court investment in the country’s ailing oil and gas sector. In August, the country’s state-owned oil and gas company, Pertamina, said it would import 1 million barrels of Iranian crude to test in domestic refineries.

Among the 11 agreements signed in Jakarta during the king’s three-day visit to the capital, before he decamped to Bali for an extended holiday, is thought to be a deal for more funds from the Saudi oil giant Aramco to expand its US$6 billion upgrade of Pertamina’s refineries.

“The Saudis tended to look down on the Indonesians and now they are coming to visit,” said Keith Lovard, an analyst with Jakarta-based business risk firm Concord Consulting. “The irony is that this is happening when Indonesia is deftly balancing the two enemies: Saudi and Iran – playing one off the other – to its benefit.”

Before the high-profile visit of the king and his entourage of 1,500, the relationship had showed signs of souring. Dozens of Indonesian Hajj pilgrims and the families of victims who were killed or injured when a crane collapsed in September 2015 have yet to receive insurance payments promised at the time of the accident. Saudi Arabia’s reputation in the Muslim world took another beating when 700 died during a stampede at a mosque in Mina, outside Mecca, a few months later. Earlier that same year, Saudi officials beheaded an Indonesian domestic worker convicted of stabbing her Saudi employer to death.

Even so, social media here has lit up with riveting details of the excess, the humorous and the downright bizarre details of the trip. The Saudi delegation arrived with 459 tonnes of luggage (not including the two limos).

Photos of an alarmed Saudi king caught in one of the frequent downpours during rainy season delighted Twitter. Nude statues that dot the botanic gardens at the Presidential Palace in Bogor, about 40km in the cool highlands outside of Jakarta, were covered with potted plants to avoid offending the Saudis.

Indonesian worries may have been overdone. During a meeting with religious leaders for 30 minutes at the main presidential palace King Salman encouraged tolerance and cautioned against religious extremism. He urged a united stand against organised terror in a 10-minute speech to the Indonesian parliament.

The aura of moderation may rub off on Widodo, who was seated beside the king when he made the statements. Widodo has come under fire by religious conservatives for protecting his protégé, Jakarta’s reformist governor Basuki Purnama. Purnama, who is better known as Ahok, is fighting blasphemy charges for allegedly insulting the Koran. He faces a tough re-election fight when Jakartans go to the polls in the second round of voting next month.

Netanyahu’s drama-free Singapore trip: Are Malaysia, Indonesia finally warming to Israel?

Wahid said that while the king’s utterances are political gold for Widodo, who is widely seen as a moderate, they may have come too late for Purnama. Half a million people took to the streets to call for his imprisonment in successive protests late last year.

“People’s minds are made up on this one,” said Wahid. “Not even the king can change things.”