LIKE a weird tropical flower, the Palace of the Light of Faith opens to subjects of the Sultan of Brunei for three days each year. It is a 1,800-room pile on the edge of Bandar Seri Begawan, the tiny state’s sleepy capital. In its vast banqueting hall thousands of Bruneians tuck into a breakfast of beef curry and honey-roast chicken, piled up on gold-rimmed plates. Later, the men queue to greet the sultan in a green-and-gold reception room (the sultan’s wife receives the women in a separate chamber). The royal family shakes tens of thousands of hands.

This annual event, held last month to celebrate the end of Ramadan, is a chance for Bruneians to praise Sultan Hassanal Bolkiah, one of the world’s richest men and few remaining absolute monarchs. They will have another chance on August 15th, when he marks his 69th birthday.

Bountiful oil has made Bruneians the fourth most wealthy people in Asia, with generous state handouts. That has helped forestall criticism of an autocratic government. But now reserves of hydrocarbons are dwindling, to which the government seems to have few answers—other than fostering a harsher form of Islam. Last year it announced plans to introduce a severe form of sharia (Islamic law).

Perched on the northern coast of the island of Borneo, surrounded to landward by Malaysia, Brunei gained full independence from Britain only in 1984, having chosen in the 1960s not to join the federation that became Malaysia. Oil has gushed since the 1920s. The money from that—plus Brunei’s firm support for ASEAN, the ten-member Association of South-East Asian Nations eyeing closer integration—lends the country of about 400,000 a clout that belies its size.

Yet Brunei is no brash Gulf emirate. The capital is quiet and surprisingly scruffy, even if Bruneians seem pretty content. The sultan, who has ruled since 1967, enjoys genuine popularity, especially among the ethnic Malays who make up the majority of the population. Bruneians pay no income tax, enjoy free education and have access to cheap home loans and social housing. Many men find comfortable jobs in government: attendance at Friday prayers and royal ceremonies is compulsory; hard work is optional.

The oil that greased the social contract

However, tumbling oil prices have begun to undermine this cosy social contract. Oil- and gasfields are ageing, their equipment increasingly costly to maintain. With petrodollars scarcer than before, Brunei’s economy has contracted for two years in a row and will shrink in 2015, when the government will run a budget deficit of 16% of GDP. The IMF has advised it to freeze public-sector wages and hiring, cut fuel subsidies and abandon big projects. It calls for measures to boost low productivity and encourage job growth.

Huge fiscal reserves provide a big cushion. But the softness points to bigger worries ahead. Without new discoveries, Brunei’s oil and gas reserves will last only 24 years, according to a report by BP, an oil company. The returns from surpluses invested overseas over the years could take up a lot of the slack. Marie-Sybille de Vienne, a French academic, guesses that the country has assets of at least $170 billion, equivalent to roughly ten times its GDP. Yet she calculates that by 2030 cash from those investments will be able to contribute 27-45% of GDP—in other words, perhaps considerably less than the 54% contribution to GDP made by oil and gas in the ten years to 2010.

The solution, it was agreed in a government-sponsored report nearly a decade ago, is to boost a private sector that accounts for only a quarter of the economy (outside the oil and gas sector). The government is building roads, bridges and power projects to draw in Japanese and other investors and encourage manufacturing, such as a much-trumpeted methanol factory. It sees opportunities in Islamic finance. It wants to make Brunei a research, certification and export hub for halal food, drugs and cosmetics. It talks of attracting more tourists, perhaps to tour its jungle which, unlike Malaysia’s next door, has not been turned into palm-oil plantations.

These attempts have brought “gradual progress”, according to the Asian Development Bank. That is polite. In the decade to 2014 Brunei’s economy expanded at an average of less than 1% a year, the slowest rate in South-East Asia and well below the 6% annual growth that the government had hoped for. A high-paying civil service continues to steal talent from private employers, while trussing them in red tape. Firms in Brunei’s halal cluster have not found it easy to meet its rigid religious standards, and tourist numbers have not grown as hoped. A strict ban on booze limits the country’s appeal to decadent infidel holidaymakers.

It is against this sluggish backdrop that the sultan is taking an ever more dogmatic line over how Brunei’s religious heritage is to be considered. Brunei’s increasingly strict Islamic penal code may soon allow for stonings and amputations. The first of three stages towards full sharia, launched in May 2014, has enforced fasting during Ramadan and brought a crackdown on Christmas and new year celebrations. The second stage, due this year but seemingly delayed, will be more severe. The change is undermining one of Brunei’s big draws for investors: a stable legal system based on English law.

Some think the new penal code aims to give Brunei’s royals more ways to quash dissent. Another, simpler theory is that the sultan, who led a wild youth, has grown more religious. Zealots assert that a more pious Brunei will probably grow faster, because Allah will perhaps let it discover more hydrocarbons. The growing consensus, as one analyst puts it, is: “You don’t need to work, but to pray.”